• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-16,74410,145

themes/H19-Aug-2021-1,098938

ui/H19-Aug-2021-35,74035,707

win32/H03-May-2022-11991

AUTHORSH A D06-May-202111.7 KiB186162

READMEH A D06-May-202115.8 KiB337265

TODOH A D06-May-20211.5 KiB4026

crossfire-client.desktopH A D06-May-2021247 109

README

1Crossfire GTKv2 Client
2======================
3Crossfire Development Team <crossfire@metalforge.org>
4:toc:
5:numbered:
6
7Overview
8--------
9The original author's main motivations for writing the client were:
10
11 . The old client layout wasn't originally designed for the map window size
12   that people are now using.
13
14 . Using an interface designer will make it much easier to add new window
15   elements in the future.
16
17 . Having a GTK 2 compliant client was considered a positive thing.
18
19Due to point #1 above, the interface was designed for a window size of about
201200x1000.  That is to say, on a system whose resolution is 1280x1024, the
21window will use almost the entire screen.  It is possible to play this client
22on a 1024x768 desktop, but the default layout is not ideal for such a small
23screen.  Some of the alternative root window layouts are more viable when
24screen real-estate is on the low side.
25
26The original author had no particular interests in patches to make it work
27on smaller screens, and originally stated that those with a requirement for
28smaller screens needed to simply use one of the other clients (Gtk v1 client
29for example).  The rationale for this stance was that there is a perception
30that the older client has a lot of cruft trying to deal with different size
31screens, options to change various sizing, etc.  Though the GTK v2 client is
32supposed to work at 1280x1000, the information density is far lower than that
33of the original GTK v1 client, and this is not palatable to some players.
34
35The author also has stated that the GTK2 client is the "most official" client,
36and has put forward the idea that if the newer GTK client could be reworked to
37resolve differences of opinion about the layout, there may be a benefit to
38phasing out the older clients.  In fact, some Linux distributions appear to be
39ceasing to build the older GTK client - likely because it is not realized that
40it may be built with the GTK2 libraries.
41
42Considering the above issues, an endeavor was undertaken to convert the client
43to use the libglade interface to allow players to have an ability to redesign
44the main window layout without requiring code changes to the clienti, and to
45preclude a need to recompile the client in order to realize a new layout.  The
46libglade version of the client should make it easier for players to create
47main window layouts that appeal to a variety of personal preferences.
48
49To support redesign of the layout, a prospective UI layout must not rename
50widgets that accept or display information.  For the most part, container
51widgets may be renamed to suite the author.  The main exception is that hpane
52and vpane widgets must be named with consistent names so that the client can
53save and restore window positions in the gwinpos2 file.  The current client
54codebase expects hpane and vpane (resizeable) widgets to be named generically
55in the form "hpaned_*" or "vpaned_*".  The code to Save Window Position
56auto-detects the widgets in order to preserve the user's pane sizing
57preferences.
58
59Design
60------
61Core Widgets
62~~~~~~~~~~~~
63  window-root: The core window.
64
65  table-map: table that contains the map and scrollbars.
66  drawingarea-map: The map drawing area.
67  hscrollbar-map: scrollbar to move the map horizontally.
68  vscrollbar-map: scrollbar to move the map horizontally.
69  button-map-recenter: When clicked, map recenters.
70
71  drawingarea-magic-map: Area to draw the magic map
72
73NOTE: The reason scrollbars are used instead of a simple scrolled window is
74that the author does not believe it is feasible to draw much more than what
75the player is currently viewing.  If a scrolled window is used, then we may
76end up drawing a lot of stuff the player is not seeing, as well as not
77redrawing fog stuff the player is seeing.  By using scrollbars, it is easier
78to trap when the player tries to scroll the map, and redraw the new portion,
79as well as track where the map is currently positioned, without needing a
80much larger draw area.
81
82  vpaned-info-inventory: seperator for the text window vs inventory area.
83  vbox-info-entry: Top portion is text information, bottom is area for text
84     entry.
85  entry-commands: Where the player enters extended commands.
86
87  notebook-info: notebook for different text information
88  textview-info1: area where messages are displayed.
89  textview-info2: area where messages are displayed.
90
91  The two info are in a tabbed area - more tabs could in fact be added.  The
92  idea is to keep the two info panes as before, but in less space.  The primary
93  tab (1) will get all messages.  Important messages (colored in this case)
94  will also go to tab 2.  Perhaps down the road, there will be smarter
95  filtering of these messages.
96
97  label-inv-weight: Shows current weight of characters inventory.
98  spinbutton-count: Current count set by the player.
99
100  notebook-inv: Notebook for the various inventory panes.
101
102  label-stats-hp:
103  label-stats-sp:
104  label-stats-grace:
105  label-stats-food: Text label showing hp/sp/
106
107  progressbar-hp:
108  progressbar-sp:
109  progressbar-grace:
110  progressbar-food: progressbar for the stats.
111
112  label-str, label-dex, label-con,label-int, label-wis, label-pow, label-cha,
113  label-wc, label-dam, label-ac, label-armor, label-range, label-exp:
114  Actual stat value for those values.
115
116  table-stats-exp: Table hold the skills and exp values.  Note that
117  initializing this is not done in Glade - it is easier to do on the
118  client side, so that it can make an array of labels for this.
119
120  table-protections: Like table-stats-exp above, but this is for protections.
121
122Note that the inventory tabs are done in the code - Glade really doesn't let
123one fully set up a gtktreewidget (the number of columns, renderer type, etc),
124so it just made it easier to do in the actual code.)
125
126Layouts
127~~~~~~~
128Two different layout files are used by the client to build its user interface.
129One is for building the main window, and the other is for constructing the
130other dialogs common to different layouts.
131
132To start the client using a different layout, use the `-window_xml` flag.
133
134    crossfire-client-gtk2 -window_xml /path/to/layout.glade
135
136If something does not work as expected, be sure to start the client from a
137console window.  The client will report informational and error messages.
138
139To specify a different common dialog XML file, append an additional
140argument on the command-line:
141
142    -dialog_xml /path/to/dialogs.glade
143
144As of SVN revision 8406, crossfire-client-gtk2 saves window position data in
145a file named per the layout instead of the legacy file '~/crossfire/gwinpos2'.
146For example, if a player saves window positions while using gtk-v2.glade,
147they will be stored in '~/.crossfire/gtk-v2.pos', but if playing with a layout
148called caelestis.glade, they will be saved in caelestis.pos.  This means the
149client is able to remember saved sizes for each layout individually.
150
151The first time a layout is used, the '~/.crossfire/<layoutname>.pos' file will
152not exist so the client will use default sizes that were defined inside the
153'<layoutname>.glade' file at design time.  This means that as long as the
154defaults are smaller than the desktop, the client window should be laid out
155nicely.
156
157If, however, the desktop size is smaller than the default sizes, the client
158may look bad, and it may be tricky to find the size bars if panes overlap.
159With patience, they may be found and used to size the client panes better.
160Use the Client Save Window Position command to save the adjustments.  They
161will be used to restore the saved settings the next time the client is
162started.
163
164If the desktop is smaller than it was last time the '.pos' file was created,
165it is possible that the saved positions are no good.  In this case, it may
166be wise to delete the '.pos' file and try out the default settings.
167
168Development
169-----------
170Here follow some notes for those wishing to do development:
171
172 . Send a note to crossfire@metalforge.org about what you plan to work on so
173   that multiple people don't work on the same thing.
174
175 . Try to work with up to date SVN to minimize merge problems.
176
177 . If looking for something to work on, look at the TODO file.
178
179 . Try to add new graphical elements using glade-2 and not coding them in by
180   hand - this will make it easier for future modifications.
181
182 . gtk2proto.h should be used to collect prototype information needed by the
183   .c sources.  It is generated using `make proto`.  The cproto program must
184   be installed for this to work.  Note that `make proto` generates a lot of
185   error messages on the console during operation, but this does not mean the
186   process failed.
187
188 . The source files are arranged by functionality, so try to keep new code
189   functionality related to similar elements in the same files, but at the
190   same time, don't put so much stuff in one file to make it unmanageable.
191
192 . One of the motivations was to use pure GTK v2 calls and not use any of the
193   deprecated wigets/toolkits withing GTK.  Please try to keep to that model
194   (note that this does not mean things are 100% perfect, as for widgets that
195   are not deprecated, I often copied the code completely over from the GTGTK
196   client, but certain functions may be deprecated in that copied code).  But
197   dealing with that is certainly easier down the road if/when those functions
198   really disappear than having to redo code for a widget that just no longer
199   exists.
200
201Designing Layouts
202~~~~~~~~~~~~~~~~~
203 . All windows that should not be initially displayed when the application
204starts must have the "visible" property set to "no".  This property is on
205the "Common" tab.
206
207The following windows should not be initially visible:
208
209     metaserver_window
210     keybinding_window
211     msgctrl_window
212     config_window
213     spell_window
214     skill_window
215     about_window
216
217
218IMPORTANT: The root window "visible" property must also be set to "no" in
219order for saved screen size settings to be restorable when the application
220starts up. This really means that all dialogs and windows should be set as
221not visible.
222
223 . All hpane and vpane resizeable widgets that need to be saved when the user
224   selects Client | Save Window Position should have a name that begins with
225   either "hpaned_" or "vpaned_".  The client will only save window positions
226   for the widgets named in this way (this is the default naming convention
227   used by the Glade Designer application).
228
229 . Set all hpaned and vpaned size bars to result in a default layout that has
230   a decent appearance.  It is not sufficient to have the layout look good in
231   the layout designer.  You must verify that the Position property on the
232   Widget tab is set and that it's checkbox is checked.  Also see note 11 for
233   another important tip regarding setting the size of widgets.
234
235 . When creating tabbed notebooks be sure the first tab is the tab that should
236   be visible when the client starts up or when the dialog is first displayed.
237
238 . Most layouts may be altered by creatively cut/pasting elements.  Do not use
239   copy/paste, as that will cause the widgets to be renamed.
240
241 . The inventory icon pane is an excellent "temporary" holding area that may
242   be used to hold widgets while other areas of the layout are being worked
243   on.
244
245 . More complex changes may be made by temporarily expanding the outer vbox
246   container and using the bottom rows to paste things into.  Be careful when
247   reducing it back to the original size.  Glade Designer deletes the bottom
248   layers first, even if there are empty ones in the middle.  Any widgets in
249   the removed layer are lost.
250
251 . Save periodically, and keep working copies.  It is very easy to ruin a
252   layout so that it is hard to return to a proper state, and widget errors
253   may cause the client to crash at run-time when it is most inconvenient.
254
255 . When adding a combo box that is to be dynamically filled at run-time, be
256   absolutely sure to press the ellipsis "..." button next to the empty Items:
257   box, then press the OK button on the Edit Text Property dialog.  This
258   causes the XML file combo box definition to contain an essential property:
259
260     <property name="items" translatable="yes"></property>
261
262Without this property, at run-time the following code snippet will set
263model to NULL.
264
265     model = gtk_combo_box_get_model(GTK_COMBO_BOX(config_combobox_theme));
266     count =  gtk_tree_model_iter_n_children(model, NULL);
267
268This construct is used several times in config.c's setup_config_window().
269When model is NULL, the subsequent code that attempts to use the model
270generates console errors like:
271
272     (crossfire-client-gtk2:9632): Gtk-CRITICAL **:
273     gtk_tree_model_iter_n_children: assertion `GTK_IS_TREE_MODEL (tree_model)'
274     failed
275
276     (crossfire-client-gtk2:9632): Gtk-CRITICAL **: gtk_combo_box_append_text:
277     assertion `GTK_IS_LIST_STORE (combo_box->priv->model)' failed
278
279     (crossfire-client-gtk2:9632): Gtk-CRITICAL **: gtk_combo_box_append_text:
280     assertion `GTK_IS_LIST_STORE (combo_box->priv->model)' failed
281
282     (crossfire-client-gtk2:9632): Gtk-CRITICAL **: gtk_combo_box_append_text:
283     assertion `GTK_IS_LIST_STORE (combo_box->priv->model)' failed
284
285     (crossfire-client-gtk2:9632): Gtk-CRITICAL **:
286     gtk_tree_model_iter_n_children: assertion `GTK_IS_TREE_MODEL (tree_model)'
287     failed
288
289 . The Magic Map page in map_notebook must be the second tab to maintain
290    compatibility with the client's standard main.h define "MAGIC_MAP_PAGE 1".
291    The page/tab number is zero-based, so "1" corresponds to the second tab.
292
293 . In general, do not set widget Width and Height properties on the Common
294   tab in the Glade Designer.  This is in effect placing a size request for
295   the widget, and can prevent the player from sizing the widget smaller than
296   the size set at design time.  This is especially important with respect to
297   the map and magic map drawing areas, tables, treeviews, and other large UI
298   elements (hboxes, vboxes, notebooks, etc).  A player should generally have
299   the freedom to make a widget smaller than it was originally designed in
300   the layout.
301
302 . Note, though, that this is not a hard and fast rule.  Sometimes setting a
303   size is very helpful.  For example, in the GTK V1 layout (and a few others)
304   progressbars are set to use a smaller height dimension size than their
305   default.  Since a player never expects to be able to set the thickness of
306   the bar, setting that dimension is useful to attain a particular look (I.E.
307   make the progressbar more compact).
308
309 . All dialogs defined in dialogs.glade should have their Deletable property
310   set to "No" in the XML (done while working in the Glade-3 designer).  This
311   tells window managers not to put an [X] close icon on the window frame.
312   Without this, the [X] close deletes the dialog so it cannot be resurrected
313   without restarting the client.  In some cases a segmentation fault occurs
314   and the client crashes.  To cover cases where certain window managers do
315   not honor the GTK Deletable property, connect the delete_event for each
316   dialog to gtk_widget_hide_on_delete() in the C code.  For example:
317
318        g_signal_connect((gpointer) about_window, "delete_event",
319            G_CALLBACK(gtk_widget_hide_on_delete), NULL);
320
321Other Hints
322~~~~~~~~~~~
323 . Sometimes when making significant layout changes or when glade misbehaves
324   and does not let you visually see an select an empty cell (vboxes have been
325   noted as problematic if an empty cell is bounded by two cells with content).
326   When this happens, it is quite possible to use a text editor to move items
327   into the empty cell.  Naturally you have to be able to look at the XML
328   structure to know how to keep it intact.  Make backups before making
329   manual edits.
330
331 . When editing .glade files by hand, use of a text editor that is capable of
332   collapsing XML structures is recommended.  Even without such and editor, it
333   can be handle to use a browser alongside the editor.  To do so, make a copy
334   of the .glade file, but save it with a .xml extension, and then open it in
335   FireFox or another XML-aware browser.  Use the expand/collapse features to
336   learn or reveal the structure of the XML.
337