convert line ends
[canaan.git] / prj / cam / src / shock / shkiftul.cpp
blob9a1f0e4bbc72673a90248edacb3929431562ad96
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/shock/shkiftul.cpp,v 1.9 2000/02/19 13:25:29 toml Exp $
8 #include <2d.h>
9 #include <appagg.h>
10 #include <res.h>
11 #include <resapi.h>
12 #include <mprintf.h>
13 #include <schema.h>
14 #include <scrnmode.h>
16 // ui library not C++ ized properly yet
17 extern "C" {
18 #include <event.h>
19 #include <gadbox.h>
20 #include <gadblist.h>
21 #include <gadbutt.h>
24 #include <shkutils.h>
25 #include <shkiftul.h>
26 #include <shkovrly.h>
27 #include <shkovcst.h>
28 #include <shkmfddm.h>
29 #include <memall.h>
30 #include <dbmem.h> // must be last header!
32 extern int gMFDRight;
34 #define NUM_NAV_BUTTONS 4
35 #define BDIM(x,y) {{x,y},{x+40,y+22}}
36 static Rect nav_rects[NUM_NAV_BUTTONS] = {
37 BDIM(15,270), BDIM(55,270), BDIM(95,270), BDIM(135,270),
39 static LGadButtonList nav_blist;
40 static LGadButtonListDesc nav_blistdesc;
41 static DrawElement nav_blist_elems[NUM_NAV_BUTTONS];
42 static IRes *nav_handles[NUM_NAV_BUTTONS][2];
43 static grs_bitmap *nav_bitmaps[NUM_NAV_BUTTONS][4];
45 char *nav_names[NUM_NAV_BUTTONS] = { "estats", "etech", "ecmbt", "epsi" };
46 //--------------------------------------------------------------------------------------
47 void ShockMFDNavButtonsInit()
49 int n,i;
50 char temp[255];
51 for (n=0; n < NUM_NAV_BUTTONS; n++)
53 for (i=0; i < 2; i++)
55 sprintf(temp,"%s%d",nav_names[n],i);
56 nav_handles[n][i] = LoadPCX(temp);
57 nav_bitmaps[n][i] = (grs_bitmap *) nav_handles[n][i]->Lock();
59 for (i = 2; i < 4; i++)
61 nav_bitmaps[n][i] = nav_bitmaps[n][0];
66 //--------------------------------------------------------------------------------------
67 void ShockMFDNavButtonsTerm()
69 int n;
70 for (n=0; n < NUM_NAV_BUTTONS; n++)
72 nav_handles[n][0]->Unlock();
73 nav_handles[n][1]->Unlock();
74 SafeFreeHnd(&nav_handles[n][0]);
75 SafeFreeHnd(&nav_handles[n][1]);
79 //--------------------------------------------------------------------------------------
80 static bool nav_cb(ushort action, int button, void* data, LGadBox* vb)
82 int which_mfd;
84 if (action == MOUSE_LDOWN)
85 SchemaPlay((Label *)"bclick2",NULL);
87 if (action != BUTTONGADG_LCLICK)
88 return(FALSE);
90 SchemaPlay((Label *)"btabs", NULL);
92 switch (button)
94 case 0: which_mfd = kOverlayStats; break;
95 case 1: which_mfd = kOverlayTechSkill; break;
96 case 2: which_mfd = kOverlaySkills; break;
97 case 3: which_mfd = kOverlayPsi; break;
98 default:
99 return(TRUE);
102 // set our "memory" of which MFD to open
103 gMFDRight = which_mfd;
105 // this will automatically turn off any conflicting MFDs
106 uiDefer(DeferOverlayOpen,(void *)which_mfd);
108 //mprintf("nav button %d\n",button);
109 return(TRUE);
112 //--------------------------------------------------------------------------------------
113 void ShockMFDNavButtonsBuild(Rect *r)
115 int n;
116 static Rect use_rects[NUM_NAV_BUTTONS];
117 // make a button for each nav dest, ie a button list
118 for (n=0; n < NUM_NAV_BUTTONS; n++)
120 DrawElement *elem = &nav_blist_elems[n];
121 elem->draw_type = DRAWTYPE_BITMAPOFFSET;
122 elem->draw_data = nav_bitmaps[n];
123 elem->draw_data2 = (void *)4; // should be 2 but hackery required
125 use_rects[n].ul.x = nav_rects[n].ul.x + r->ul.x;
126 use_rects[n].ul.y = nav_rects[n].ul.y + r->ul.y;
127 use_rects[n].lr.x = nav_rects[n].lr.x + r->ul.x;
128 use_rects[n].lr.y = nav_rects[n].lr.y + r->ul.y;
131 nav_blistdesc.num_buttons = NUM_NAV_BUTTONS;
132 nav_blistdesc.button_rects = use_rects;
133 nav_blistdesc.button_elems = nav_blist_elems;
134 nav_blistdesc.cb = nav_cb;
136 LGadCreateButtonListDesc(&nav_blist, LGadCurrentRoot(), &nav_blistdesc);
139 //--------------------------------------------------------------------------------------
140 void ShockMFDNavButtonsDestroy()
142 LGadDestroyBox(VB(&nav_blist),FALSE);
145 //--------------------------------------------------------------------------------------
146 void ShockMFDNavButtonsDraw()
148 LGadDrawBox(VB(&nav_blist),NULL);
150 //--------------------------------------------------------------------------------------
152 void SetLeftMFDRect(int which, Rect full_rect)
154 sScrnMode smode;
155 ScrnModeGet(&smode);
157 if (smode.w == 640)
158 ShockOverlaySetRect(which, full_rect);
159 else
161 short w,h;
162 Rect use_rect;
163 w = RectWidth(&full_rect);
164 h = RectHeight(&full_rect);
165 use_rect.ul.x = full_rect.ul.x;
166 if (smode.w >= 1024)
167 use_rect.ul.y = full_rect.ul.y - LMFD_Y;
168 else
169 use_rect.ul.y = smode.h - LMFD_H - 56;
170 use_rect.lr.x = use_rect.ul.x + w;
171 use_rect.lr.y = use_rect.ul.y + h;
172 ShockOverlaySetRect(which, use_rect);
176 //--------------------------------------------------------------------------------------
177 void SetRightMFDRect(int which, Rect full_rect)
179 sScrnMode smode;
180 ScrnModeGet(&smode);
182 if (smode.w == 640)
183 ShockOverlaySetRect(which, full_rect);
184 else
186 short w,h;
187 Rect use_rect;
188 w = RectWidth(&full_rect);
189 h = RectHeight(&full_rect);
190 use_rect.ul.x = smode.w - (640 - full_rect.ul.x);
191 if (smode.w >= 1024)
192 use_rect.ul.y = full_rect.ul.y - RMFD_Y;
193 else
194 use_rect.ul.y = smode.h - RMFD_H - 56;
195 use_rect.lr.x = use_rect.ul.x + w;
196 use_rect.lr.y = use_rect.ul.y + h;
197 ShockOverlaySetRect(which, use_rect);
200 //--------------------------------------------------------------------------------------