2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/shock/shkiftul.cpp,v 1.9 2000/02/19 13:25:29 toml Exp $
16 // ui library not C++ ized properly yet
30 #include <dbmem.h> // must be last header!
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()
51 for (n
=0; n
< NUM_NAV_BUTTONS
; n
++)
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()
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
)
84 if (action
== MOUSE_LDOWN
)
85 SchemaPlay((Label
*)"bclick2",NULL
);
87 if (action
!= BUTTONGADG_LCLICK
)
90 SchemaPlay((Label
*)"btabs", NULL
);
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;
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);
112 //--------------------------------------------------------------------------------------
113 void ShockMFDNavButtonsBuild(Rect
*r
)
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
)
158 ShockOverlaySetRect(which
, full_rect
);
163 w
= RectWidth(&full_rect
);
164 h
= RectHeight(&full_rect
);
165 use_rect
.ul
.x
= full_rect
.ul
.x
;
167 use_rect
.ul
.y
= full_rect
.ul
.y
- LMFD_Y
;
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
)
183 ShockOverlaySetRect(which
, full_rect
);
188 w
= RectWidth(&full_rect
);
189 h
= RectHeight(&full_rect
);
190 use_rect
.ul
.x
= smode
.w
- (640 - full_rect
.ul
.x
);
192 use_rect
.ul
.y
= full_rect
.ul
.y
- RMFD_Y
;
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 //--------------------------------------------------------------------------------------