1 /*
2 **
3 **	X11 Jewel By David Cooper and Jose Guterman 05/92
4 **
5 */
6 
7 #ifdef VMS
8 #include <decw$include/Xlib.h>
9 #include <decw$include/Xutil.h>
10 #include <decw$include/Xos.h>
11 #else
12 #include <X11/Xlib.h>
13 #include <X11/Xutil.h>
14 #include <X11/Xos.h>
15 #endif
16 
17 #include "general.h"
18 #include "logic.h"
19 #include "jewel.h"
20 #include "xhscore.h"
21 #include "xw.h"
22 
23 
24 XFontStruct *SymbolFont;
25 GC SymbolGC;
26 XFontStruct *HeaderFont;
27 GC HeaderGC;
28 #define SYMBOL_FONT "-adobe-symbol-*-*-*-*-18-*-*-*-*-*-adobe-*"
29 #define HEADER_FONT "-*-*-bold-r-*-*-24-*-*-*-p-*-iso8859-1"
30 #define HEADER_LOC_Y 100
31 #define HELP_LEFT_X 100
32 #define HELP_RIGHT_X (SCREEN_X - HELP_LEFT_X)
33 char *HeaderString = "\253\253\253 Keys \273\273\273";
34 
35 #define NUM_HELP 6
36 static char *HelpStrings[NUM_HELP][3]=
37 	{
38 		{ "\254", ", j, 4 ",     " Move Block Left", },
39 		{ "\255", ", k, 5 ",     " Rotate Block", },
40 		{ "\256", ", l, 6 ",     " Move Block Right", },
41 		{ "\257", ", Space, 0 ", " Drop Block", },
42 		{ " ", "P, p", " Pause/unPause", },
43 		{ " ", "U, u", " Iconify and Pause", },
44 	};
45 
46 
Expose_Help()47 void Expose_Help()
48 	{
49 	int i, y;
50 	XCharStruct Sizes;
51 	int dir, asc, dsc;
52 
53 	y=HEADER_LOC_Y;
54 
55 	XTextExtents(HeaderFont,HeaderString,strlen(HeaderString),
56 		&dir,&asc,&dsc,&Sizes);
57 	XDrawImageString(xw_display, xw_window, HeaderGC,
58 		(SCREEN_X - (Sizes.width))/2 , y,
59 		HeaderString, strlen(HeaderString));
60 
61 	for (i=0; i< NUM_HELP; i++)
62 		{
63 		int len;
64 		y+=((HeaderFont->ascent+HeaderFont->descent)*2);
65 		/* draw keypad */
66 		len=strlen(HelpStrings[i][0]);
67 		XTextExtents(SymbolFont,HelpStrings[i][0],len,
68 			&dir,&asc,&dsc,&Sizes);
69 		XDrawImageString(xw_display, xw_window, SymbolGC,
70 			HELP_LEFT_X, y, HelpStrings[i][0],len);
71 		/* draw keyboard */
72 		len=strlen(HelpStrings[i][1]);
73 		XDrawImageString(xw_display, xw_window, HeaderGC,
74 			(HELP_LEFT_X + Sizes.width), y, HelpStrings[i][1], len);
75 		/* draw operations */
76 		len=strlen(HelpStrings[i][2]);
77 		XTextExtents(HeaderFont,HelpStrings[i][2],len,
78 			&dir,&asc,&dsc,&Sizes);
79 		XDrawImageString(xw_display, xw_window, HeaderGC,
80 			(HELP_RIGHT_X - Sizes.width), y, HelpStrings[i][2], len);
81 		}
82 
83 	XTextExtents(VerFont,StartString, strlen(StartString),
84 		&dir,&asc,&dsc,&Sizes);
85 	XDrawImageString(xw_display, xw_window, VerGC,
86 		(SCREEN_X - Sizes.width)/2,
87 		START_LOC_Y+((VerFont->ascent)*3/2),
88 		StartString, strlen(StartString));
89 
90 	XDrawImageString(xw_display, xw_window, VerGC, VER_LOC_X,
91 		VER_LOC_Y+((VerFont->ascent)*3/2),
92 		VerString, strlen(VerString));
93 	XFlush(xw_display);
94 	}
95 
96 
Start_Help()97 void Start_Help()
98 	{
99 	XClearWindow(xw_display, xw_window);
100 
101 	Expose_Help();
102 	JewelState=HELP;
103 	xw_set_timer(10000L);
104 	}
105 
Init_Help()106 void Init_Help()
107 	{
108 	XGCValues gcv;
109 	unsigned long gcvm;
110 
111 	gcvm=(GCFont | GCGraphicsExposures | GCForeground | GCBackground);
112 
113 	gcv.graphics_exposures=False;
114 	gcv.foreground=white;
115 	gcv.background=black;
116 
117 	if ( (SymbolFont=XLoadQueryFont(xw_display,SYMBOL_FONT)) == NULL)
118 		{ xw_fatal("Cannot load SYMBOL font.\n",__LINE__,__FILE__); }
119 	gcv.font=SymbolFont->fid;
120 	SymbolGC=XCreateGC(xw_display, xw_window, gcvm, &gcv);
121 
122 	if ( (HeaderFont=XLoadQueryFont(xw_display,HEADER_FONT)) == NULL)
123 		{ xw_fatal("Cannot load HEADER font.\n",__LINE__,__FILE__); }
124 	gcv.font=HeaderFont->fid;
125 	HeaderGC=XCreateGC(xw_display, xw_window, gcvm, &gcv);
126 	}
127