• R/O
  • SSH
  • HTTPS

marathon: コミット


コミットメタ情報

リビジョン526 (tree)
日時2012-06-02 14:08:40
作者ookawa_mi

ログメッセージ

1.0.2対応
改行コード修正

変更サマリ

差分

--- marathon/trunk/Source_Files/Misc/PlayerDialogs.cpp (revision 525)
+++ marathon/trunk/Source_Files/Misc/PlayerDialogs.cpp (revision 526)
@@ -1,1007 +1,1007 @@
1-/*
2-
3- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
4- and the "Aleph One" developers.
5-
6- This program is free software; you can redistribute it and/or modify
7- it under the terms of the GNU General Public License as published by
8- the Free Software Foundation; either version 3 of the License, or
9- (at your option) any later version.
10-
11- This program is distributed in the hope that it will be useful,
12- but WITHOUT ANY WARRANTY; without even the implied warranty of
13- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- GNU General Public License for more details.
15-
16- This license is contained in the file "COPYING",
17- which is included with this source code; it is available online at
18- http://www.gnu.org/licenses/gpl.html
19-
20- February 21, 2000 (Loren Petrich)
21-
22- These are some extra dialog routines associated with setting such player stuff
23- as the chase cam and the crosshairs.
24-
25- Feb 25, 2000 (Loren Petrich):
26-
27- Split the rendering routines up into routines that need different parameters.
28-
29- Feb 26, 2000 (Loren Petrich):
30- Added support for "on when entering" for the chase cam when a game starts.
31-
32- Jun 11, 2000 (Loren Petrich):
33- Used a class created for the checkboxes
34-
35-Jan 25, 2002 (Br'fin (Jeremy Parsons)):
36- Added accessors for datafields now opaque in Carbon
37-
38-Feb 5, 2002 (Br'fin (Jeremy Parsons)):
39- Put player chase cam and crosshair dialogs in sheets under Carbon
40-
41-Feb 14, 2002 (Br'fin (Jeremy Parsons)):
42- Made the Carbon sheets backgrounds transparent
43-
44-Jun 26, 2002 (Loren Petrich):
45- Added support for additional crosshairs features;
46- included revert on bad value for crosshairs dialog
47-*/
48-
49-#include "cseries.h"
50-#include "interface.h"
51-#include "world.h"
52-#include "ChaseCam.h"
53-#include "Crosshairs.h"
54-#include "OGL_Setup.h"
55-#include "MacCheckbox.h"
56-#include "shell.h"
57-#include <math.h>
58-#include <stdio.h>
59-
60-#ifdef USES_NIBS
61- #include "NibsUiHelpers.h"
62-#endif
63-
64-const float FLOAT_WORLD_ONE = float(WORLD_ONE);
65-
66-#ifdef USES_NIBS
67-
68-const CFStringRef Window_Prefs_ChaseCam = CFSTR("Prefs_ChaseCam");
69-
70-const CFStringRef Window_Prefs_Crosshairs = CFSTR("Prefs_Crosshairs");
71-
72-#endif
73-
74-enum
75-{
76- OK_Item = 1,
77- Cancel_Item = 2,
78-
79- ChaseCam_Dialog = 1500,
80- Behind_Item = 5,
81- Upward_Item = 7,
82- Rightward_Item = 9,
83- PassThruWall_Item = 10,
84- NeverActive_Item = 11,
85- OnWhenEntering_Item = 12,
86- VoidColorOnOff_Item = 13,
87- VoidColorSelect_Item = 14,
88- Damping_Item = 16,
89- Spring_Item = 18,
90- CC_Opacity_Item = 20,
91- VerifyNumbers_Item = 21,
92-
93- Crosshairs_Dialog = 1600,
94- Thickness_Item = 5,
95- FromCenter_Item = 7,
96- Length_Item = 9,
97- GetColor_Item = 10,
98- Show_Item = 11,
99- Preview_Item = 12,
100- BkgdColor_Item = 13,
101- Shape_Item = 14,
102- CH_Opacity_Item = 16
103-};
104-
105-// Background color
106-static RGBColor BkgdColor = rgb_black;
107-
108-
109-#ifdef USES_NIBS
110-
111-
112-// These need to return whether the text field was correctly parsed or not
113-
114-static bool GetShort(ControlRef Ctrl, short& Value)
115-{
116- GetEditCText(Ctrl, temporary);
117- return (sscanf(temporary, "%hd", &Value) == 1);
118-}
119-
120-static bool GetFloat(ControlRef Ctrl, float& Value)
121-{
122- GetEditCText(Ctrl, temporary);
123- return (sscanf(temporary, "%f", &Value) == 1);
124-}
125-
126-static void SetShort(ControlRef Ctrl, short Value)
127-{
128- sprintf(temporary, "%hd", Value);
129- SetEditCText(Ctrl, temporary);
130-}
131-
132-static void SetFloat(ControlRef Ctrl, float Value)
133-{
134- sprintf(temporary, "%f", Value);
135- SetEditCText(Ctrl, temporary);
136-}
137-
138-static int FloatRoundoff(float x)
139-{
140- return (x >= 0) ? int(x + 0.5) : - int(-x + 0.5);
141-}
142-
143-
144-struct Configure_ChaseCam_HandlerData
145-{
146- // All these must be verified
147- ControlRef BehindCtrl;
148- ControlRef UpwardCtrl;
149- ControlRef RightwardCtrl;
150- ControlRef DampingCtrl;
151- ControlRef SpringCtrl;
152- ControlRef CC_OpacityCtrl;
153-
154- // Void color to be picked
155- RGBColor VoidColor;
156-
157- // Verifies and performs necessary adjustments;
158- // returns whether all values were OK
159- bool VerifyAndAdjust();
160-};
161-
162-bool Configure_ChaseCam_HandlerData::VerifyAndAdjust()
163-{
164- float Temp;
165- float Damping, Spring;
166- bool IsOK = true;
167-
168- // First, check the spring-constant factors
169- if (GetFloat(DampingCtrl,Damping))
170- {
171- // Simple damping-factor validation
172- float NewTemp = PIN(Damping, -1, 1);
173- if (NewTemp != Damping)
174- {
175- Damping = NewTemp;
176- SetFloat(DampingCtrl,Damping);
177- IsOK = false;
178- }
179- }
180- else
181- IsOK = false;
182-
183- IsOK = IsOK && GetFloat(SpringCtrl,Spring);
184-
185- if (IsOK)
186- {
187- // Do validation: will the chase cam be unstable?
188-
189- if (Spring >= 0)
190- {
191- // Oscillatory case
192- float DampSq = Damping*Damping;
193- if ((DampSq + Spring) >= 1)
194- {
195- Spring = 1 - DampSq;
196- SetFloat(SpringCtrl,Spring);
197- IsOK = false;
198- }
199- }
200- else
201- {
202- // Overdamped case
203- float DampAbs = fabs(Damping);
204- if ((DampAbs + sqrt(-Spring)) >= 1)
205- {
206- float DACmpl = 1 - DampAbs;
207- Spring = - DACmpl*DACmpl;
208- SetFloat(SpringCtrl,Spring);
209- IsOK = false;
210- }
211- }
212- }
213-
214- // Don't really need these values here
215- IsOK = IsOK && GetFloat(BehindCtrl,Temp);
216- IsOK = IsOK && GetFloat(UpwardCtrl,Temp);
217- IsOK = IsOK && GetFloat(RightwardCtrl,Temp);
218-
219- // Get the opacity to within a reasonable range
220- if (GetFloat(CC_OpacityCtrl,Temp))
221- {
222- float NewTemp = PIN(Temp, 0, 1);
223- if (NewTemp != Temp)
224- {
225- SetFloat(CC_OpacityCtrl, NewTemp);
226- IsOK = false;
227- }
228- }
229- else
230- IsOK = false;
231-
232- if (!IsOK) SysBeep(30);
233-
234- return IsOK;
235-}
236-
237-
238-static void Configure_ChaseCam_Handler(ParsedControl &Ctrl, void *Data)
239-{
240- Configure_ChaseCam_HandlerData *HDPtr = (Configure_ChaseCam_HandlerData *)(Data);
241-
242- switch (Ctrl.ID.id)
243- {
244- case VoidColorSelect_Item:
245- PickControlColor(Ctrl.Ctrl, &HDPtr->VoidColor, "\pSelect Color of Void");
246- break;
247-
248- case VerifyNumbers_Item:
249- HDPtr->VerifyAndAdjust();
250- break;
251- }
252-}
253-
254-
255-// True for OK, false for cancel
256-bool Configure_ChaseCam(ChaseCamData &Data)
257-{
258- // Get the window
259- AutoNibReference Nib (Window_Prefs_ChaseCam);
260- AutoNibWindow Window (Nib.nibReference (), Window_Prefs_ChaseCam);
261-
262- // Get the controls
263- Configure_ChaseCam_HandlerData HandlerData;
264-
265- HandlerData.BehindCtrl = GetCtrlFromWindow(Window(), 0, Behind_Item);
266- SetFloat(HandlerData.BehindCtrl,Data.Behind/FLOAT_WORLD_ONE);
267-
268- HandlerData.UpwardCtrl = GetCtrlFromWindow(Window(), 0, Upward_Item);
269- SetFloat(HandlerData.UpwardCtrl,Data.Upward/FLOAT_WORLD_ONE);
270-
271- HandlerData.RightwardCtrl = GetCtrlFromWindow(Window(), 0, Rightward_Item);
272- SetFloat(HandlerData.RightwardCtrl,Data.Rightward/FLOAT_WORLD_ONE);
273-
274- HandlerData.DampingCtrl = GetCtrlFromWindow(Window(), 0, Damping_Item);
275- SetFloat(HandlerData.DampingCtrl,Data.Damping);
276-
277- HandlerData.SpringCtrl = GetCtrlFromWindow(Window(), 0, Spring_Item);
278- SetFloat(HandlerData.SpringCtrl,Data.Spring);
279-
280- HandlerData.CC_OpacityCtrl = GetCtrlFromWindow(Window(), 0, CC_Opacity_Item);
281- SetFloat(HandlerData.CC_OpacityCtrl,Data.Opacity);
282-
283- ControlRef PassThruWall_Ctrl = GetCtrlFromWindow(Window(), 0, PassThruWall_Item);
284- SetControl32BitValue(PassThruWall_Ctrl, !!TEST_FLAG(Data.Flags,_ChaseCam_ThroughWalls));
285-
286- ControlRef NeverActive_Ctrl = GetCtrlFromWindow(Window(), 0, NeverActive_Item);
287- SetControl32BitValue(NeverActive_Ctrl, !!TEST_FLAG(Data.Flags,_ChaseCam_NeverActive));
288-
289- ControlRef OnWhenEntering_Ctrl = GetCtrlFromWindow(Window(), 0, OnWhenEntering_Item);
290- SetControl32BitValue(OnWhenEntering_Ctrl, !!TEST_FLAG(Data.Flags,_ChaseCam_OnWhenEntering));
291-
292- // Get void color from OpenGL-parameters data
293- OGL_ConfigureData& OGLData = Get_OGL_ConfigureData();
294-
295- ControlRef VoidColorOnOff_Ctrl = GetCtrlFromWindow(Window(), 0, VoidColorOnOff_Item);
296- SetControl32BitValue(VoidColorOnOff_Ctrl, !!TEST_FLAG(OGLData.Flags,OGL_Flag_VoidColor));
297-
298- HandlerData.VoidColor = OGLData.VoidColor;
299-
300- // For making the swatch drawable and hittable
301- AutoDrawability Drawability;
302- AutoHittability Hittability;
303-
304- ControlRef VoidSwatchCtrl = GetCtrlFromWindow(Window(), 0, VoidColorSelect_Item);
305-
306- Drawability(VoidSwatchCtrl, SwatchDrawer, &HandlerData.VoidColor);
307- Hittability(VoidSwatchCtrl);
308-
309- bool IsOK = RunModalDialog(Window(), true, Configure_ChaseCam_Handler, &HandlerData);
310-
311- if (IsOK)
312- {
313- HandlerData.VerifyAndAdjust();
314-
315- float Temp;
316-
317- if (GetFloat(HandlerData.BehindCtrl,Temp))
318- Data.Behind = FloatRoundoff(FLOAT_WORLD_ONE*Temp);
319-
320- if (GetFloat(HandlerData.UpwardCtrl,Temp));
321- Data.Upward = FloatRoundoff(FLOAT_WORLD_ONE*Temp);
322-
323- if (GetFloat(HandlerData.RightwardCtrl,Temp));
324- Data.Rightward = FloatRoundoff(FLOAT_WORLD_ONE*Temp);
325-
326- GetFloat(HandlerData.DampingCtrl, Data.Damping);
327-
328- GetFloat(HandlerData.SpringCtrl, Data.Spring);
329-
330- GetFloat(HandlerData.CC_OpacityCtrl, Data.Opacity);
331-
332- SET_FLAG(Data.Flags,_ChaseCam_ThroughWalls,GetControl32BitValue(PassThruWall_Ctrl));
333-
334- SET_FLAG(Data.Flags,_ChaseCam_NeverActive,GetControl32BitValue(NeverActive_Ctrl));
335-
336- SET_FLAG(Data.Flags,_ChaseCam_OnWhenEntering,GetControl32BitValue(OnWhenEntering_Ctrl));
337-
338- SET_FLAG(OGLData.Flags,OGL_Flag_VoidColor,GetControl32BitValue(VoidColorOnOff_Ctrl));
339-
340- OGLData.VoidColor = HandlerData.VoidColor;
341- }
342-
343- return IsOK;
344-}
345-
346-
347-#else
348-
349-// These need to return whether the text field was correctly parsed or not
350-
351-static bool GetShort(ControlHandle Hdl, short& Value)
352-{
353- GetDialogItemText((Handle)Hdl,ptemporary);
354- ptemporary[ptemporary[0]+1] = 0;
355- return (sscanf(temporary+1,"%hd",&Value) == 1);
356-}
357-
358-static bool GetFloat(ControlHandle Hdl, float& Value)
359-{
360- GetDialogItemText((Handle)Hdl,ptemporary);
361- ptemporary[ptemporary[0]+1] = 0;
362- return (sscanf(temporary+1,"%f",&Value) == 1);
363-}
364-
365-static void SetShort(ControlHandle Hdl, short Value)
366-{
367- NumToString(Value,ptemporary);
368- SetDialogItemText((Handle)Hdl, ptemporary);
369-}
370-
371-static void SetFloat(ControlHandle Hdl, float Value)
372-{
373- psprintf(ptemporary, "%f",Value);
374- SetDialogItemText((Handle)Hdl, ptemporary);
375-}
376-
377-/*
378-static void ToggleControl(ControlHandle Hdl)
379-{
380- SetControlValue(Hdl, 1 - GetControlValue(Hdl));
381-}
382-*/
383-
384-static int FloatRoundoff(float x)
385-{
386- return (x >= 0) ? int(x + 0.5) : - int(-x + 0.5);
387-}
388-
389-
390-// True for OK, false for cancel
391-bool Configure_ChaseCam(ChaseCamData &Data)
392-{
393- short ItemType;
394- Rect Bounds;
395-
396- DialogPtr Dialog = myGetNewDialog(ChaseCam_Dialog, NULL, (WindowPtr)(-1), 0);
397- assert(Dialog);
398-
399- ControlHandle Behind_CHdl;
400- GetDialogItem(Dialog, Behind_Item, &ItemType, (Handle *)&Behind_CHdl, &Bounds);
401- SetFloat(Behind_CHdl,Data.Behind/FLOAT_WORLD_ONE);
402-
403- ControlHandle Upward_CHdl;
404- GetDialogItem(Dialog, Upward_Item, &ItemType, (Handle *)&Upward_CHdl, &Bounds);
405- SetFloat(Upward_CHdl,Data.Upward/FLOAT_WORLD_ONE);
406-
407- ControlHandle Rightward_CHdl;
408- GetDialogItem(Dialog, Rightward_Item, &ItemType, (Handle *)&Rightward_CHdl, &Bounds);
409- SetFloat(Rightward_CHdl,Data.Rightward/FLOAT_WORLD_ONE);
410-
411- MacCheckbox PassThruWall_CB(Dialog, PassThruWall_Item, TEST_FLAG(Data.Flags,_ChaseCam_ThroughWalls));
412- MacCheckbox NeverActive_CB(Dialog, NeverActive_Item, TEST_FLAG(Data.Flags,_ChaseCam_NeverActive));
413- MacCheckbox OnWhenEntering_CB(Dialog, OnWhenEntering_Item, TEST_FLAG(Data.Flags,_ChaseCam_OnWhenEntering));
414-
415- ControlHandle Damping_CHdl;
416- GetDialogItem(Dialog, Damping_Item, &ItemType, (Handle *)&Damping_CHdl, &Bounds);
417- SetFloat(Damping_CHdl,Data.Damping);
418-
419- ControlHandle Spring_CHdl;
420- GetDialogItem(Dialog, Spring_Item, &ItemType, (Handle *)&Spring_CHdl, &Bounds);
421- SetFloat(Spring_CHdl,Data.Spring);
422-
423- ControlHandle Opacity_CHdl;
424- GetDialogItem(Dialog, CC_Opacity_Item, &ItemType, (Handle *)&Opacity_CHdl, &Bounds);
425- SetFloat(Opacity_CHdl,Data.Opacity);
426-
427- // Where to make the color picker
428- Point Center = {-1,-1};
429- RGBColor NewColor;
430- // Get void color from OpenGL-parameters data
431- OGL_ConfigureData& OGLData = Get_OGL_ConfigureData();
432- MacCheckbox VoidColorOnOff_CB(Dialog, VoidColorOnOff_Item, TEST_FLAG(OGLData.Flags,OGL_Flag_VoidColor));
433-
434- // Reveal it
435-#if USE_SHEETS
436- SetThemeWindowBackground(GetDialogWindow(Dialog), kThemeBrushSheetBackgroundTransparent, false);
437- ShowSheetWindow(GetDialogWindow(Dialog), ActiveNonFloatingWindow());
438-#else
439- SelectWindow(GetDialogWindow(Dialog));
440- ShowWindow(GetDialogWindow(Dialog));
441-#endif
442-
443- bool WillQuit = false;
444- bool IsOK = false;
445- short New_Behind = 0, New_Upward = 0, New_Rightward = 0;
446- float FloatTemp = 0;
447- bool BadValue;
448- float New_Damping, New_Spring, New_Opacity;
449- while(!WillQuit)
450- {
451- short ItemHit;
452- ModalDialog(NULL, &ItemHit);
453-
454- switch(ItemHit)
455- {
456- case OK_Item:
457- // Check before quitting
458- BadValue = false;
459-
460- // Now doing roundoff correctly
461- // Using a modification of AlexJLS's corrected version
462-
463- if (GetFloat(Behind_CHdl,FloatTemp))
464- New_Behind = FloatRoundoff(WORLD_ONE * FloatTemp);
465- else
466- BadValue = true;
467-
468- if (GetFloat(Upward_CHdl,FloatTemp))
469- New_Upward = FloatRoundoff(WORLD_ONE * FloatTemp);
470- else
471- BadValue = true;
472-
473- if (GetFloat(Rightward_CHdl,FloatTemp))
474- New_Rightward = FloatRoundoff(WORLD_ONE * FloatTemp);
475- else
476- BadValue = true;
477-
478- if (GetFloat(Damping_CHdl,FloatTemp))
479- {
480- // Simple validation of the damping factor
481- New_Damping = PIN(FloatTemp,-1,1);
482- if (New_Damping != FloatTemp)
483- {
484- BadValue = true;
485- SetFloat(Damping_CHdl,New_Damping);
486- }
487- }
488- else
489- BadValue = true;
490-
491- if (GetFloat(Spring_CHdl,FloatTemp))
492- {
493- New_Spring = FloatTemp;
494- }
495- else
496- BadValue = true;
497-
498- if (GetFloat(Opacity_CHdl,FloatTemp))
499- {
500- New_Opacity = PIN(FloatTemp,0,1);
501- if (New_Opacity != FloatTemp)
502- {
503- BadValue = true;
504- SetFloat(Opacity_CHdl,New_Opacity);
505- }
506- }
507- else
508- BadValue = true;
509-
510- // Do validation: will the chase cam be unstable?
511- if (!BadValue)
512- {
513- if (New_Spring >= 0)
514- {
515- // Oscillatory case
516- float NewDampSq = New_Damping*New_Damping;
517- BadValue = ((NewDampSq + New_Spring) >= 1);
518- if (BadValue)
519- {
520- New_Spring = 1 - NewDampSq;
521- SetFloat(Spring_CHdl,New_Spring);
522- }
523- }
524- else
525- {
526- // Overdamped case
527- float NewDampAbs = fabs(New_Damping);
528- BadValue = ((NewDampAbs + sqrt(-New_Spring)) >= 1);
529- if (BadValue)
530- {
531- float Temp = 1 - NewDampAbs;
532- New_Spring = - Temp*Temp;
533- SetFloat(Spring_CHdl,New_Spring);
534- }
535- }
536- }
537-
538- if (BadValue)
539- {
540- SysBeep(30);
541- break;
542- }
543-
544- IsOK = true;
545- WillQuit = true;
546- break;
547-
548- case Cancel_Item:
549- IsOK = false;
550- WillQuit = true;
551- break;
552-
553- case VoidColorSelect_Item:
554- // Need to set color here so the preview can work properly
555- if (GetColor(Center,"\pWhat color for the void?",&OGLData.VoidColor,&NewColor))
556- OGLData.VoidColor = NewColor;
557- break;
558-
559- default:
560- if (PassThruWall_CB.ToggleIfHit(ItemHit)) break;
561- if (NeverActive_CB.ToggleIfHit(ItemHit)) break;
562- if (OnWhenEntering_CB.ToggleIfHit(ItemHit)) break;
563- if (VoidColorOnOff_CB.ToggleIfHit(ItemHit)) break;
564- break;
565- }
566- }
567-
568- if (IsOK)
569- {
570- Data.Behind = New_Behind;
571- Data.Upward = New_Upward;
572- Data.Rightward = New_Rightward;
573- SET_FLAG(Data.Flags,_ChaseCam_ThroughWalls,PassThruWall_CB.GetState());
574- SET_FLAG(Data.Flags,_ChaseCam_NeverActive,NeverActive_CB.GetState());
575- SET_FLAG(Data.Flags,_ChaseCam_OnWhenEntering,OnWhenEntering_CB.GetState());
576- SET_FLAG(OGLData.Flags,OGL_Flag_VoidColor,VoidColorOnOff_CB.GetState());
577- Data.Damping = New_Damping;
578- Data.Spring = New_Spring;
579- Data.Opacity = New_Opacity;
580- }
581-
582- // Clean up
583-#if USE_SHEETS
584- HideSheetWindow(GetDialogWindow(Dialog));
585-#else
586- HideWindow(GetDialogWindow(Dialog));
587-#endif
588- DisposeDialog(Dialog);
589-
590- return IsOK;
591-}
592-
593-
594-#endif
595-
596-
597-#ifdef USES_NIBS
598-
599-
600-void PreviewDrawer(ControlRef Ctrl, void *Data)
601-{
602- // Don't need the data arg here
603- CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data
604-
605- // No need for the window context -- it's assumed
606- Rect Bounds = {0,0,0,0};
607-
608- GetControlBounds(Ctrl, &Bounds);
609-
610- // Get ready to draw!
611- PenNormal();
612-
613- // Draw the background
614- RGBForeColor(&BkgdColor);
615- PaintRect(&Bounds);
616-
617- // Clip to inside of box
618- ClipRect(&Bounds);
619-
620- // Draw the crosshairs
621- Crosshairs_Render(Bounds);
622-
623- // Draw the boundary line
624- ForeColor(blackColor);
625- FrameRect(&Bounds);
626-}
627-
628-
629-struct Configure_Crosshair_HandlerData
630-{
631- // Will need to read off of these controls
632- ControlRef ThicknessCtrl;
633- ControlRef FromCenterCtrl;
634- ControlRef LengthCtrl;
635- ControlRef OpacityCtrl;
636- ControlRef ShapeCtrl;
637-
638- ControlRef ShowCtrl;
639- // Background color is a global
640-};
641-
642-
643-static void Configure_Crosshair_Handler(ParsedControl &Ctrl, void *Data)
644-{
645- Configure_Crosshair_HandlerData *HDPtr = (Configure_Crosshair_HandlerData *)Data;
646-
647- CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data
648-
649- bool IsOK;
650-
651- switch(Ctrl.ID.id)
652- {
653- case Shape_Item:
654- case Preview_Item:
655-
656- // Update the crosshair data
657- IsOK = true;
658-
659- IsOK = IsOK && GetShort(HDPtr->ThicknessCtrl, Crosshairs.Thickness);
660-
661- IsOK = IsOK && GetShort(HDPtr->FromCenterCtrl, Crosshairs.FromCenter);
662-
663- IsOK = IsOK && GetShort(HDPtr->LengthCtrl, Crosshairs.Length);
664-
665- IsOK = IsOK && GetFloat(HDPtr->OpacityCtrl, Crosshairs.Opacity);
666-
667- if (!IsOK) SysBeep(30);
668-
669- Crosshairs.Shape = GetControl32BitValue(HDPtr->ShapeCtrl) - 1;
670-
671- Draw1Control(HDPtr->ShowCtrl);
672-
673- break;
674-
675- case GetColor_Item:
676- PickControlColor(HDPtr->ShowCtrl, &Crosshairs.Color, "\pSelect Crosshair Color");
677- break;
678-
679- case BkgdColor_Item:
680- PickControlColor(HDPtr->ShowCtrl, &BkgdColor, "\pSelect Background Color");
681- break;
682- }
683-}
684-
685-
686-// True for OK, false for cancel
687-bool Configure_Crosshairs(CrosshairData &Data)
688-{
689-
690- // Get the window
691- AutoNibReference Nib (Window_Prefs_Crosshairs);
692- AutoNibWindow Window (Nib.nibReference (), Window_Prefs_Crosshairs);
693-
694- // Push old crosshair state;
695- // will always want to draw it
696- bool OldCrosshairActive = Crosshairs_IsActive();
697- Crosshairs_SetActive(true);
698- CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data
699- CrosshairData OldCrosshairs = Crosshairs;
700-
701- // Get the controls
702- Configure_Crosshair_HandlerData HandlerData;
703-
704- HandlerData.ThicknessCtrl = GetCtrlFromWindow(Window(), 0, Thickness_Item);
705- SetShort(HandlerData.ThicknessCtrl, Crosshairs.Thickness);
706-
707- HandlerData.FromCenterCtrl = GetCtrlFromWindow(Window(), 0, FromCenter_Item);
708- SetShort(HandlerData.FromCenterCtrl, Crosshairs.FromCenter);
709-
710- HandlerData.LengthCtrl = GetCtrlFromWindow(Window(), 0, Length_Item);
711- SetShort(HandlerData.LengthCtrl, Crosshairs.Length);
712-
713- HandlerData.OpacityCtrl = GetCtrlFromWindow(Window(), 0, CH_Opacity_Item);
714- SetFloat(HandlerData.OpacityCtrl, Crosshairs.Opacity);
715-
716- HandlerData.ShapeCtrl = GetCtrlFromWindow(Window(), 0, Shape_Item);
717- SetControl32BitValue(HandlerData.ShapeCtrl, Crosshairs.Shape+1);
718-
719- // For making the preview drawable
720- AutoDrawability Drawability;
721-
722- HandlerData.ShowCtrl = GetCtrlFromWindow(Window(), 0, Show_Item);
723-
724- Drawability(HandlerData.ShowCtrl, PreviewDrawer);
725-
726- bool IsOK = RunModalDialog(Window(), true, Configure_Crosshair_Handler, &HandlerData);
727-
728- // Save the new color, in case we want it
729- RGBColor Color = Crosshairs.Color;
730-
731- // Pop old crosshair state
732- Crosshairs_SetActive(OldCrosshairActive);
733- Crosshairs = OldCrosshairs;
734-
735- // After that popping, just in case that data is the data being currently edited
736- if (IsOK)
737- {
738- GetShort(HandlerData.ThicknessCtrl, Crosshairs.Thickness);
739-
740- GetShort(HandlerData.FromCenterCtrl, Crosshairs.FromCenter);
741-
742- GetShort(HandlerData.LengthCtrl, Crosshairs.Length);
743-
744- GetFloat(HandlerData.OpacityCtrl, Crosshairs.Opacity);
745-
746- Crosshairs.Shape = GetControl32BitValue(HandlerData.ShapeCtrl) - 1;
747-
748- Crosshairs.Color = Color;
749- }
750-
751- // Reset OpenGL precalculation
752- Crosshairs.PreCalced = false;
753-
754- return IsOK;
755-}
756-
757-
758-#else
759-
760-
761-// Procedure for displaying the preview
762-static pascal void DoPreview(DialogPtr Dialog, short ItemNo)
763-{
764- // Get essential stuff on the item to receive the preview
765- short ItemType;
766- Rect Bounds;
767- ControlHandle CHdl;
768- GetDialogItem(Dialog, ItemNo, &ItemType, (Handle *)&CHdl, &Bounds);
769-
770- // Push previous state
771- PenState OldPen;
772- RGBColor OldBackColor, OldForeColor;
773-
774- GetPenState(&OldPen);
775- GetBackColor(&OldBackColor);
776- GetForeColor(&OldForeColor);
777-
778- // Get ready to do the drawing
779- PenNormal();
780-
781- // Draw the background
782- RGBForeColor(&BkgdColor);
783- PaintRect(&Bounds);
784-
785- // Push old crosshair state
786- bool OldCrosshairState = Crosshairs_IsActive();
787- Crosshairs_SetActive(true);
788-
789- // Clip to inside of box
790- ClipRect(&Bounds);
791-
792- // Draw the crosshairs
793- Crosshairs_Render(Bounds);
794-
795- // No more clipping
796- Rect portRect;
797- GetPortBounds(GetWindowPort(GetDialogWindow(Dialog)), &portRect);
798- ClipRect(&portRect);
799-
800- // Pop old crosshair state
801- Crosshairs_SetActive(OldCrosshairState);
802-
803- // Draw the boundary line
804- RGBForeColor(&rgb_black);
805- FrameRect(&Bounds);
806-
807- // Pop previous state
808- SetPenState(&OldPen);
809- RGBBackColor(&OldBackColor);
810- RGBForeColor(&OldForeColor);
811-}
812-
813-
814-// True for OK, false for cancel
815-bool Configure_Crosshairs(CrosshairData &Data)
816-{
817- short ItemType;
818- Rect Bounds;
819-
820- DialogPtr Dialog = myGetNewDialog(Crosshairs_Dialog, NULL, (WindowPtr)(-1), 0);
821- assert(Dialog);
822-
823- ControlHandle Thickness_CHdl;
824- GetDialogItem(Dialog, Thickness_Item, &ItemType, (Handle *)&Thickness_CHdl, &Bounds);
825- SetShort(Thickness_CHdl,Data.Thickness);
826-
827- ControlHandle FromCenter_CHdl;
828- GetDialogItem(Dialog, FromCenter_Item, &ItemType, (Handle *)&FromCenter_CHdl, &Bounds);
829- SetShort(FromCenter_CHdl,Data.FromCenter);
830-
831- ControlHandle Length_CHdl;
832- GetDialogItem(Dialog, Length_Item, &ItemType, (Handle *)&Length_CHdl, &Bounds);
833- SetShort(Length_CHdl,Data.Length);
834-
835- ControlHandle Shape_CHdl;
836- GetDialogItem(Dialog, Shape_Item, &ItemType, (Handle *)&Shape_CHdl, &Bounds);
837- SetControlValue(Shape_CHdl,Data.Shape+1);
838-
839- ControlHandle Opacity_CHdl;
840- GetDialogItem(Dialog, CH_Opacity_Item, &ItemType, (Handle *)&Opacity_CHdl, &Bounds);
841- SetFloat(Opacity_CHdl,Data.Opacity);
842-
843- // Create a UPP for the crosshair preview and store it
844- UserItemUPP DoPreviewUPP = NewUserItemUPP(DoPreview);
845- ControlHandle Show_CHdl;
846- GetDialogItem(Dialog, Show_Item, &ItemType, (Handle *)&Show_CHdl, &Bounds);
847- SetDialogItem(Dialog, Show_Item, ItemType, Handle(DoPreviewUPP), &Bounds);
848-
849- // Where to make the color picker
850- Point Center = {-1,-1};
851-
852- // Remembering the old values is necessary for the preview to work properly
853- CrosshairData SavedData = Data;
854-
855- // Reveal it
856-#if USE_SHEETS
857- SetThemeWindowBackground(GetDialogWindow(Dialog), kThemeBrushSheetBackgroundTransparent, false);
858- ShowSheetWindow(GetDialogWindow(Dialog), ActiveNonFloatingWindow());
859-#else
860- SelectWindow(GetDialogWindow(Dialog));
861- ShowWindow(GetDialogWindow(Dialog));
862-#endif
863-
864- bool WillQuit = false;
865- bool IsOK = false;
866- short ShortTemp;
867- float FloatTemp;
868- RGBColor NewColor;
869- bool BadValue, OverallBadValue;
870- while(!WillQuit)
871- {
872- short ItemHit;
873- ModalDialog(NULL, &ItemHit);
874-
875- switch(ItemHit)
876- {
877- case OK_Item:
878- case Preview_Item:
879- // Check before quitting or redrawing;
880- OverallBadValue = false;
881-
882- BadValue = false;
883- if (GetShort(Thickness_CHdl,ShortTemp))
884- {
885- if (ShortTemp > 0)
886- Data.Thickness = ShortTemp;
887- else
888- BadValue = true;
889- } else
890- BadValue = true;
891-
892- if (BadValue)
893- {
894- SetShort(Thickness_CHdl,Data.Thickness);
895- OverallBadValue = true;
896- }
897-
898- BadValue = false;
899- if (GetShort(FromCenter_CHdl,ShortTemp))
900- {
901- if (ShortTemp >= 0)
902- Data.FromCenter = ShortTemp;
903- else
904- BadValue = true;
905- } else
906- BadValue = true;
907-
908- if (BadValue)
909- {
910- SetShort(FromCenter_CHdl,Data.FromCenter);
911- OverallBadValue = true;
912- }
913-
914- BadValue = false;
915- if (GetShort(Length_CHdl,ShortTemp))
916- {
917- if (ShortTemp > 0)
918- Data.Length = ShortTemp;
919- else
920- BadValue = true;
921- } else
922- BadValue = true;
923-
924- if (BadValue)
925- {
926- SetShort(Length_CHdl,Data.Length);
927- OverallBadValue = true;
928- }
929-
930- BadValue = false;
931- if (GetFloat(Opacity_CHdl,FloatTemp))
932- {
933- if (FloatTemp >= 0 && FloatTemp <= 1)
934- Data.Opacity = FloatTemp;
935- else
936- BadValue = true;
937- } else
938- BadValue = true;
939-
940- if (BadValue)
941- {
942- SetFloat(Opacity_CHdl,Data.Opacity);
943- OverallBadValue = true;
944- }
945-
946- Data.Shape = GetControlValue(Shape_CHdl)-1;
947-
948- if (OverallBadValue)
949- {
950- SysBeep(30);
951- DrawDialog(Dialog); // To do the reversion correctly
952- break;
953- }
954-
955- switch(ItemHit)
956- {
957- case Preview_Item:
958- DrawDialog(Dialog);
959- break;
960-
961- case OK_Item:
962- IsOK = true;
963- WillQuit = true;
964- break;
965- }
966- break;
967-
968- case Cancel_Item:
969- IsOK = false;
970- WillQuit = true;
971- break;
972-
973- case GetColor_Item:
974- // Need to set color here so the preview can work properly
975- if (GetColor(Center,"\pWhat crosshair color?",&Data.Color,&NewColor))
976- Data.Color = NewColor;
977- DrawDialog(Dialog);
978- break;
979-
980- case BkgdColor_Item:
981- if (GetColor(Center,"\pWhat preview background color?",&BkgdColor,&NewColor))
982- BkgdColor = NewColor;
983- DrawDialog(Dialog);
984- break;
985- }
986- }
987-
988- if (!IsOK)
989- {
990- // Revert all these values
991- Data = SavedData;
992- }
993-
994- // Clean up
995-#if USE_SHEETS
996- HideSheetWindow(GetDialogWindow(Dialog));
997-#else
998- HideWindow(GetDialogWindow(Dialog));
999-#endif
1000-
1001- DisposeUserItemUPP(DoPreviewUPP);
1002- DisposeDialog(Dialog);
1003-
1004- return IsOK;
1005-}
1006-
1007-#endif
1+/*
2+
3+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
4+ and the "Aleph One" developers.
5+
6+ This program is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
10+
11+ This program is distributed in the hope that it will be useful,
12+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ GNU General Public License for more details.
15+
16+ This license is contained in the file "COPYING",
17+ which is included with this source code; it is available online at
18+ http://www.gnu.org/licenses/gpl.html
19+
20+ February 21, 2000 (Loren Petrich)
21+
22+ These are some extra dialog routines associated with setting such player stuff
23+ as the chase cam and the crosshairs.
24+
25+ Feb 25, 2000 (Loren Petrich):
26+
27+ Split the rendering routines up into routines that need different parameters.
28+
29+ Feb 26, 2000 (Loren Petrich):
30+ Added support for "on when entering" for the chase cam when a game starts.
31+
32+ Jun 11, 2000 (Loren Petrich):
33+ Used a class created for the checkboxes
34+
35+Jan 25, 2002 (Br'fin (Jeremy Parsons)):
36+ Added accessors for datafields now opaque in Carbon
37+
38+Feb 5, 2002 (Br'fin (Jeremy Parsons)):
39+ Put player chase cam and crosshair dialogs in sheets under Carbon
40+
41+Feb 14, 2002 (Br'fin (Jeremy Parsons)):
42+ Made the Carbon sheets backgrounds transparent
43+
44+Jun 26, 2002 (Loren Petrich):
45+ Added support for additional crosshairs features;
46+ included revert on bad value for crosshairs dialog
47+*/
48+
49+#include "cseries.h"
50+#include "interface.h"
51+#include "world.h"
52+#include "ChaseCam.h"
53+#include "Crosshairs.h"
54+#include "OGL_Setup.h"
55+#include "MacCheckbox.h"
56+#include "shell.h"
57+#include <math.h>
58+#include <stdio.h>
59+
60+#ifdef USES_NIBS
61+ #include "NibsUiHelpers.h"
62+#endif
63+
64+const float FLOAT_WORLD_ONE = float(WORLD_ONE);
65+
66+#ifdef USES_NIBS
67+
68+const CFStringRef Window_Prefs_ChaseCam = CFSTR("Prefs_ChaseCam");
69+
70+const CFStringRef Window_Prefs_Crosshairs = CFSTR("Prefs_Crosshairs");
71+
72+#endif
73+
74+enum
75+{
76+ OK_Item = 1,
77+ Cancel_Item = 2,
78+
79+ ChaseCam_Dialog = 1500,
80+ Behind_Item = 5,
81+ Upward_Item = 7,
82+ Rightward_Item = 9,
83+ PassThruWall_Item = 10,
84+ NeverActive_Item = 11,
85+ OnWhenEntering_Item = 12,
86+ VoidColorOnOff_Item = 13,
87+ VoidColorSelect_Item = 14,
88+ Damping_Item = 16,
89+ Spring_Item = 18,
90+ CC_Opacity_Item = 20,
91+ VerifyNumbers_Item = 21,
92+
93+ Crosshairs_Dialog = 1600,
94+ Thickness_Item = 5,
95+ FromCenter_Item = 7,
96+ Length_Item = 9,
97+ GetColor_Item = 10,
98+ Show_Item = 11,
99+ Preview_Item = 12,
100+ BkgdColor_Item = 13,
101+ Shape_Item = 14,
102+ CH_Opacity_Item = 16
103+};
104+
105+// Background color
106+static RGBColor BkgdColor = rgb_black;
107+
108+
109+#ifdef USES_NIBS
110+
111+
112+// These need to return whether the text field was correctly parsed or not
113+
114+static bool GetShort(ControlRef Ctrl, short& Value)
115+{
116+ GetEditCText(Ctrl, temporary);
117+ return (sscanf(temporary, "%hd", &Value) == 1);
118+}
119+
120+static bool GetFloat(ControlRef Ctrl, float& Value)
121+{
122+ GetEditCText(Ctrl, temporary);
123+ return (sscanf(temporary, "%f", &Value) == 1);
124+}
125+
126+static void SetShort(ControlRef Ctrl, short Value)
127+{
128+ sprintf(temporary, "%hd", Value);
129+ SetEditCText(Ctrl, temporary);
130+}
131+
132+static void SetFloat(ControlRef Ctrl, float Value)
133+{
134+ sprintf(temporary, "%f", Value);
135+ SetEditCText(Ctrl, temporary);
136+}
137+
138+static int FloatRoundoff(float x)
139+{
140+ return (x >= 0) ? int(x + 0.5) : - int(-x + 0.5);
141+}
142+
143+
144+struct Configure_ChaseCam_HandlerData
145+{
146+ // All these must be verified
147+ ControlRef BehindCtrl;
148+ ControlRef UpwardCtrl;
149+ ControlRef RightwardCtrl;
150+ ControlRef DampingCtrl;
151+ ControlRef SpringCtrl;
152+ ControlRef CC_OpacityCtrl;
153+
154+ // Void color to be picked
155+ RGBColor VoidColor;
156+
157+ // Verifies and performs necessary adjustments;
158+ // returns whether all values were OK
159+ bool VerifyAndAdjust();
160+};
161+
162+bool Configure_ChaseCam_HandlerData::VerifyAndAdjust()
163+{
164+ float Temp;
165+ float Damping, Spring;
166+ bool IsOK = true;
167+
168+ // First, check the spring-constant factors
169+ if (GetFloat(DampingCtrl,Damping))
170+ {
171+ // Simple damping-factor validation
172+ float NewTemp = PIN(Damping, -1, 1);
173+ if (NewTemp != Damping)
174+ {
175+ Damping = NewTemp;
176+ SetFloat(DampingCtrl,Damping);
177+ IsOK = false;
178+ }
179+ }
180+ else
181+ IsOK = false;
182+
183+ IsOK = IsOK && GetFloat(SpringCtrl,Spring);
184+
185+ if (IsOK)
186+ {
187+ // Do validation: will the chase cam be unstable?
188+
189+ if (Spring >= 0)
190+ {
191+ // Oscillatory case
192+ float DampSq = Damping*Damping;
193+ if ((DampSq + Spring) >= 1)
194+ {
195+ Spring = 1 - DampSq;
196+ SetFloat(SpringCtrl,Spring);
197+ IsOK = false;
198+ }
199+ }
200+ else
201+ {
202+ // Overdamped case
203+ float DampAbs = fabs(Damping);
204+ if ((DampAbs + sqrt(-Spring)) >= 1)
205+ {
206+ float DACmpl = 1 - DampAbs;
207+ Spring = - DACmpl*DACmpl;
208+ SetFloat(SpringCtrl,Spring);
209+ IsOK = false;
210+ }
211+ }
212+ }
213+
214+ // Don't really need these values here
215+ IsOK = IsOK && GetFloat(BehindCtrl,Temp);
216+ IsOK = IsOK && GetFloat(UpwardCtrl,Temp);
217+ IsOK = IsOK && GetFloat(RightwardCtrl,Temp);
218+
219+ // Get the opacity to within a reasonable range
220+ if (GetFloat(CC_OpacityCtrl,Temp))
221+ {
222+ float NewTemp = PIN(Temp, 0, 1);
223+ if (NewTemp != Temp)
224+ {
225+ SetFloat(CC_OpacityCtrl, NewTemp);
226+ IsOK = false;
227+ }
228+ }
229+ else
230+ IsOK = false;
231+
232+ if (!IsOK) SysBeep(30);
233+
234+ return IsOK;
235+}
236+
237+
238+static void Configure_ChaseCam_Handler(ParsedControl &Ctrl, void *Data)
239+{
240+ Configure_ChaseCam_HandlerData *HDPtr = (Configure_ChaseCam_HandlerData *)(Data);
241+
242+ switch (Ctrl.ID.id)
243+ {
244+ case VoidColorSelect_Item:
245+ PickControlColor(Ctrl.Ctrl, &HDPtr->VoidColor, "\pSelect Color of Void");
246+ break;
247+
248+ case VerifyNumbers_Item:
249+ HDPtr->VerifyAndAdjust();
250+ break;
251+ }
252+}
253+
254+
255+// True for OK, false for cancel
256+bool Configure_ChaseCam(ChaseCamData &Data)
257+{
258+ // Get the window
259+ AutoNibReference Nib (Window_Prefs_ChaseCam);
260+ AutoNibWindow Window (Nib.nibReference (), Window_Prefs_ChaseCam);
261+
262+ // Get the controls
263+ Configure_ChaseCam_HandlerData HandlerData;
264+
265+ HandlerData.BehindCtrl = GetCtrlFromWindow(Window(), 0, Behind_Item);
266+ SetFloat(HandlerData.BehindCtrl,Data.Behind/FLOAT_WORLD_ONE);
267+
268+ HandlerData.UpwardCtrl = GetCtrlFromWindow(Window(), 0, Upward_Item);
269+ SetFloat(HandlerData.UpwardCtrl,Data.Upward/FLOAT_WORLD_ONE);
270+
271+ HandlerData.RightwardCtrl = GetCtrlFromWindow(Window(), 0, Rightward_Item);
272+ SetFloat(HandlerData.RightwardCtrl,Data.Rightward/FLOAT_WORLD_ONE);
273+
274+ HandlerData.DampingCtrl = GetCtrlFromWindow(Window(), 0, Damping_Item);
275+ SetFloat(HandlerData.DampingCtrl,Data.Damping);
276+
277+ HandlerData.SpringCtrl = GetCtrlFromWindow(Window(), 0, Spring_Item);
278+ SetFloat(HandlerData.SpringCtrl,Data.Spring);
279+
280+ HandlerData.CC_OpacityCtrl = GetCtrlFromWindow(Window(), 0, CC_Opacity_Item);
281+ SetFloat(HandlerData.CC_OpacityCtrl,Data.Opacity);
282+
283+ ControlRef PassThruWall_Ctrl = GetCtrlFromWindow(Window(), 0, PassThruWall_Item);
284+ SetControl32BitValue(PassThruWall_Ctrl, !!TEST_FLAG(Data.Flags,_ChaseCam_ThroughWalls));
285+
286+ ControlRef NeverActive_Ctrl = GetCtrlFromWindow(Window(), 0, NeverActive_Item);
287+ SetControl32BitValue(NeverActive_Ctrl, !!TEST_FLAG(Data.Flags,_ChaseCam_NeverActive));
288+
289+ ControlRef OnWhenEntering_Ctrl = GetCtrlFromWindow(Window(), 0, OnWhenEntering_Item);
290+ SetControl32BitValue(OnWhenEntering_Ctrl, !!TEST_FLAG(Data.Flags,_ChaseCam_OnWhenEntering));
291+
292+ // Get void color from OpenGL-parameters data
293+ OGL_ConfigureData& OGLData = Get_OGL_ConfigureData();
294+
295+ ControlRef VoidColorOnOff_Ctrl = GetCtrlFromWindow(Window(), 0, VoidColorOnOff_Item);
296+ SetControl32BitValue(VoidColorOnOff_Ctrl, !!TEST_FLAG(OGLData.Flags,OGL_Flag_VoidColor));
297+
298+ HandlerData.VoidColor = OGLData.VoidColor;
299+
300+ // For making the swatch drawable and hittable
301+ AutoDrawability Drawability;
302+ AutoHittability Hittability;
303+
304+ ControlRef VoidSwatchCtrl = GetCtrlFromWindow(Window(), 0, VoidColorSelect_Item);
305+
306+ Drawability(VoidSwatchCtrl, SwatchDrawer, &HandlerData.VoidColor);
307+ Hittability(VoidSwatchCtrl);
308+
309+ bool IsOK = RunModalDialog(Window(), true, Configure_ChaseCam_Handler, &HandlerData);
310+
311+ if (IsOK)
312+ {
313+ HandlerData.VerifyAndAdjust();
314+
315+ float Temp;
316+
317+ if (GetFloat(HandlerData.BehindCtrl,Temp))
318+ Data.Behind = FloatRoundoff(FLOAT_WORLD_ONE*Temp);
319+
320+ if (GetFloat(HandlerData.UpwardCtrl,Temp));
321+ Data.Upward = FloatRoundoff(FLOAT_WORLD_ONE*Temp);
322+
323+ if (GetFloat(HandlerData.RightwardCtrl,Temp));
324+ Data.Rightward = FloatRoundoff(FLOAT_WORLD_ONE*Temp);
325+
326+ GetFloat(HandlerData.DampingCtrl, Data.Damping);
327+
328+ GetFloat(HandlerData.SpringCtrl, Data.Spring);
329+
330+ GetFloat(HandlerData.CC_OpacityCtrl, Data.Opacity);
331+
332+ SET_FLAG(Data.Flags,_ChaseCam_ThroughWalls,GetControl32BitValue(PassThruWall_Ctrl));
333+
334+ SET_FLAG(Data.Flags,_ChaseCam_NeverActive,GetControl32BitValue(NeverActive_Ctrl));
335+
336+ SET_FLAG(Data.Flags,_ChaseCam_OnWhenEntering,GetControl32BitValue(OnWhenEntering_Ctrl));
337+
338+ SET_FLAG(OGLData.Flags,OGL_Flag_VoidColor,GetControl32BitValue(VoidColorOnOff_Ctrl));
339+
340+ OGLData.VoidColor = HandlerData.VoidColor;
341+ }
342+
343+ return IsOK;
344+}
345+
346+
347+#else
348+
349+// These need to return whether the text field was correctly parsed or not
350+
351+static bool GetShort(ControlHandle Hdl, short& Value)
352+{
353+ GetDialogItemText((Handle)Hdl,ptemporary);
354+ ptemporary[ptemporary[0]+1] = 0;
355+ return (sscanf(temporary+1,"%hd",&Value) == 1);
356+}
357+
358+static bool GetFloat(ControlHandle Hdl, float& Value)
359+{
360+ GetDialogItemText((Handle)Hdl,ptemporary);
361+ ptemporary[ptemporary[0]+1] = 0;
362+ return (sscanf(temporary+1,"%f",&Value) == 1);
363+}
364+
365+static void SetShort(ControlHandle Hdl, short Value)
366+{
367+ NumToString(Value,ptemporary);
368+ SetDialogItemText((Handle)Hdl, ptemporary);
369+}
370+
371+static void SetFloat(ControlHandle Hdl, float Value)
372+{
373+ psprintf(ptemporary, "%f",Value);
374+ SetDialogItemText((Handle)Hdl, ptemporary);
375+}
376+
377+/*
378+static void ToggleControl(ControlHandle Hdl)
379+{
380+ SetControlValue(Hdl, 1 - GetControlValue(Hdl));
381+}
382+*/
383+
384+static int FloatRoundoff(float x)
385+{
386+ return (x >= 0) ? int(x + 0.5) : - int(-x + 0.5);
387+}
388+
389+
390+// True for OK, false for cancel
391+bool Configure_ChaseCam(ChaseCamData &Data)
392+{
393+ short ItemType;
394+ Rect Bounds;
395+
396+ DialogPtr Dialog = myGetNewDialog(ChaseCam_Dialog, NULL, (WindowPtr)(-1), 0);
397+ assert(Dialog);
398+
399+ ControlHandle Behind_CHdl;
400+ GetDialogItem(Dialog, Behind_Item, &ItemType, (Handle *)&Behind_CHdl, &Bounds);
401+ SetFloat(Behind_CHdl,Data.Behind/FLOAT_WORLD_ONE);
402+
403+ ControlHandle Upward_CHdl;
404+ GetDialogItem(Dialog, Upward_Item, &ItemType, (Handle *)&Upward_CHdl, &Bounds);
405+ SetFloat(Upward_CHdl,Data.Upward/FLOAT_WORLD_ONE);
406+
407+ ControlHandle Rightward_CHdl;
408+ GetDialogItem(Dialog, Rightward_Item, &ItemType, (Handle *)&Rightward_CHdl, &Bounds);
409+ SetFloat(Rightward_CHdl,Data.Rightward/FLOAT_WORLD_ONE);
410+
411+ MacCheckbox PassThruWall_CB(Dialog, PassThruWall_Item, TEST_FLAG(Data.Flags,_ChaseCam_ThroughWalls));
412+ MacCheckbox NeverActive_CB(Dialog, NeverActive_Item, TEST_FLAG(Data.Flags,_ChaseCam_NeverActive));
413+ MacCheckbox OnWhenEntering_CB(Dialog, OnWhenEntering_Item, TEST_FLAG(Data.Flags,_ChaseCam_OnWhenEntering));
414+
415+ ControlHandle Damping_CHdl;
416+ GetDialogItem(Dialog, Damping_Item, &ItemType, (Handle *)&Damping_CHdl, &Bounds);
417+ SetFloat(Damping_CHdl,Data.Damping);
418+
419+ ControlHandle Spring_CHdl;
420+ GetDialogItem(Dialog, Spring_Item, &ItemType, (Handle *)&Spring_CHdl, &Bounds);
421+ SetFloat(Spring_CHdl,Data.Spring);
422+
423+ ControlHandle Opacity_CHdl;
424+ GetDialogItem(Dialog, CC_Opacity_Item, &ItemType, (Handle *)&Opacity_CHdl, &Bounds);
425+ SetFloat(Opacity_CHdl,Data.Opacity);
426+
427+ // Where to make the color picker
428+ Point Center = {-1,-1};
429+ RGBColor NewColor;
430+ // Get void color from OpenGL-parameters data
431+ OGL_ConfigureData& OGLData = Get_OGL_ConfigureData();
432+ MacCheckbox VoidColorOnOff_CB(Dialog, VoidColorOnOff_Item, TEST_FLAG(OGLData.Flags,OGL_Flag_VoidColor));
433+
434+ // Reveal it
435+#if USE_SHEETS
436+ SetThemeWindowBackground(GetDialogWindow(Dialog), kThemeBrushSheetBackgroundTransparent, false);
437+ ShowSheetWindow(GetDialogWindow(Dialog), ActiveNonFloatingWindow());
438+#else
439+ SelectWindow(GetDialogWindow(Dialog));
440+ ShowWindow(GetDialogWindow(Dialog));
441+#endif
442+
443+ bool WillQuit = false;
444+ bool IsOK = false;
445+ short New_Behind = 0, New_Upward = 0, New_Rightward = 0;
446+ float FloatTemp = 0;
447+ bool BadValue;
448+ float New_Damping, New_Spring, New_Opacity;
449+ while(!WillQuit)
450+ {
451+ short ItemHit;
452+ ModalDialog(NULL, &ItemHit);
453+
454+ switch(ItemHit)
455+ {
456+ case OK_Item:
457+ // Check before quitting
458+ BadValue = false;
459+
460+ // Now doing roundoff correctly
461+ // Using a modification of AlexJLS's corrected version
462+
463+ if (GetFloat(Behind_CHdl,FloatTemp))
464+ New_Behind = FloatRoundoff(WORLD_ONE * FloatTemp);
465+ else
466+ BadValue = true;
467+
468+ if (GetFloat(Upward_CHdl,FloatTemp))
469+ New_Upward = FloatRoundoff(WORLD_ONE * FloatTemp);
470+ else
471+ BadValue = true;
472+
473+ if (GetFloat(Rightward_CHdl,FloatTemp))
474+ New_Rightward = FloatRoundoff(WORLD_ONE * FloatTemp);
475+ else
476+ BadValue = true;
477+
478+ if (GetFloat(Damping_CHdl,FloatTemp))
479+ {
480+ // Simple validation of the damping factor
481+ New_Damping = PIN(FloatTemp,-1,1);
482+ if (New_Damping != FloatTemp)
483+ {
484+ BadValue = true;
485+ SetFloat(Damping_CHdl,New_Damping);
486+ }
487+ }
488+ else
489+ BadValue = true;
490+
491+ if (GetFloat(Spring_CHdl,FloatTemp))
492+ {
493+ New_Spring = FloatTemp;
494+ }
495+ else
496+ BadValue = true;
497+
498+ if (GetFloat(Opacity_CHdl,FloatTemp))
499+ {
500+ New_Opacity = PIN(FloatTemp,0,1);
501+ if (New_Opacity != FloatTemp)
502+ {
503+ BadValue = true;
504+ SetFloat(Opacity_CHdl,New_Opacity);
505+ }
506+ }
507+ else
508+ BadValue = true;
509+
510+ // Do validation: will the chase cam be unstable?
511+ if (!BadValue)
512+ {
513+ if (New_Spring >= 0)
514+ {
515+ // Oscillatory case
516+ float NewDampSq = New_Damping*New_Damping;
517+ BadValue = ((NewDampSq + New_Spring) >= 1);
518+ if (BadValue)
519+ {
520+ New_Spring = 1 - NewDampSq;
521+ SetFloat(Spring_CHdl,New_Spring);
522+ }
523+ }
524+ else
525+ {
526+ // Overdamped case
527+ float NewDampAbs = fabs(New_Damping);
528+ BadValue = ((NewDampAbs + sqrt(-New_Spring)) >= 1);
529+ if (BadValue)
530+ {
531+ float Temp = 1 - NewDampAbs;
532+ New_Spring = - Temp*Temp;
533+ SetFloat(Spring_CHdl,New_Spring);
534+ }
535+ }
536+ }
537+
538+ if (BadValue)
539+ {
540+ SysBeep(30);
541+ break;
542+ }
543+
544+ IsOK = true;
545+ WillQuit = true;
546+ break;
547+
548+ case Cancel_Item:
549+ IsOK = false;
550+ WillQuit = true;
551+ break;
552+
553+ case VoidColorSelect_Item:
554+ // Need to set color here so the preview can work properly
555+ if (GetColor(Center,"\pWhat color for the void?",&OGLData.VoidColor,&NewColor))
556+ OGLData.VoidColor = NewColor;
557+ break;
558+
559+ default:
560+ if (PassThruWall_CB.ToggleIfHit(ItemHit)) break;
561+ if (NeverActive_CB.ToggleIfHit(ItemHit)) break;
562+ if (OnWhenEntering_CB.ToggleIfHit(ItemHit)) break;
563+ if (VoidColorOnOff_CB.ToggleIfHit(ItemHit)) break;
564+ break;
565+ }
566+ }
567+
568+ if (IsOK)
569+ {
570+ Data.Behind = New_Behind;
571+ Data.Upward = New_Upward;
572+ Data.Rightward = New_Rightward;
573+ SET_FLAG(Data.Flags,_ChaseCam_ThroughWalls,PassThruWall_CB.GetState());
574+ SET_FLAG(Data.Flags,_ChaseCam_NeverActive,NeverActive_CB.GetState());
575+ SET_FLAG(Data.Flags,_ChaseCam_OnWhenEntering,OnWhenEntering_CB.GetState());
576+ SET_FLAG(OGLData.Flags,OGL_Flag_VoidColor,VoidColorOnOff_CB.GetState());
577+ Data.Damping = New_Damping;
578+ Data.Spring = New_Spring;
579+ Data.Opacity = New_Opacity;
580+ }
581+
582+ // Clean up
583+#if USE_SHEETS
584+ HideSheetWindow(GetDialogWindow(Dialog));
585+#else
586+ HideWindow(GetDialogWindow(Dialog));
587+#endif
588+ DisposeDialog(Dialog);
589+
590+ return IsOK;
591+}
592+
593+
594+#endif
595+
596+
597+#ifdef USES_NIBS
598+
599+
600+void PreviewDrawer(ControlRef Ctrl, void *Data)
601+{
602+ // Don't need the data arg here
603+ CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data
604+
605+ // No need for the window context -- it's assumed
606+ Rect Bounds = {0,0,0,0};
607+
608+ GetControlBounds(Ctrl, &Bounds);
609+
610+ // Get ready to draw!
611+ PenNormal();
612+
613+ // Draw the background
614+ RGBForeColor(&BkgdColor);
615+ PaintRect(&Bounds);
616+
617+ // Clip to inside of box
618+ ClipRect(&Bounds);
619+
620+ // Draw the crosshairs
621+ Crosshairs_Render(Bounds);
622+
623+ // Draw the boundary line
624+ ForeColor(blackColor);
625+ FrameRect(&Bounds);
626+}
627+
628+
629+struct Configure_Crosshair_HandlerData
630+{
631+ // Will need to read off of these controls
632+ ControlRef ThicknessCtrl;
633+ ControlRef FromCenterCtrl;
634+ ControlRef LengthCtrl;
635+ ControlRef OpacityCtrl;
636+ ControlRef ShapeCtrl;
637+
638+ ControlRef ShowCtrl;
639+ // Background color is a global
640+};
641+
642+
643+static void Configure_Crosshair_Handler(ParsedControl &Ctrl, void *Data)
644+{
645+ Configure_Crosshair_HandlerData *HDPtr = (Configure_Crosshair_HandlerData *)Data;
646+
647+ CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data
648+
649+ bool IsOK;
650+
651+ switch(Ctrl.ID.id)
652+ {
653+ case Shape_Item:
654+ case Preview_Item:
655+
656+ // Update the crosshair data
657+ IsOK = true;
658+
659+ IsOK = IsOK && GetShort(HDPtr->ThicknessCtrl, Crosshairs.Thickness);
660+
661+ IsOK = IsOK && GetShort(HDPtr->FromCenterCtrl, Crosshairs.FromCenter);
662+
663+ IsOK = IsOK && GetShort(HDPtr->LengthCtrl, Crosshairs.Length);
664+
665+ IsOK = IsOK && GetFloat(HDPtr->OpacityCtrl, Crosshairs.Opacity);
666+
667+ if (!IsOK) SysBeep(30);
668+
669+ Crosshairs.Shape = GetControl32BitValue(HDPtr->ShapeCtrl) - 1;
670+
671+ Draw1Control(HDPtr->ShowCtrl);
672+
673+ break;
674+
675+ case GetColor_Item:
676+ PickControlColor(HDPtr->ShowCtrl, &Crosshairs.Color, "\pSelect Crosshair Color");
677+ break;
678+
679+ case BkgdColor_Item:
680+ PickControlColor(HDPtr->ShowCtrl, &BkgdColor, "\pSelect Background Color");
681+ break;
682+ }
683+}
684+
685+
686+// True for OK, false for cancel
687+bool Configure_Crosshairs(CrosshairData &Data)
688+{
689+
690+ // Get the window
691+ AutoNibReference Nib (Window_Prefs_Crosshairs);
692+ AutoNibWindow Window (Nib.nibReference (), Window_Prefs_Crosshairs);
693+
694+ // Push old crosshair state;
695+ // will always want to draw it
696+ bool OldCrosshairActive = Crosshairs_IsActive();
697+ Crosshairs_SetActive(true);
698+ CrosshairData &Crosshairs = GetCrosshairData(); // An alias for the global crosshair data
699+ CrosshairData OldCrosshairs = Crosshairs;
700+
701+ // Get the controls
702+ Configure_Crosshair_HandlerData HandlerData;
703+
704+ HandlerData.ThicknessCtrl = GetCtrlFromWindow(Window(), 0, Thickness_Item);
705+ SetShort(HandlerData.ThicknessCtrl, Crosshairs.Thickness);
706+
707+ HandlerData.FromCenterCtrl = GetCtrlFromWindow(Window(), 0, FromCenter_Item);
708+ SetShort(HandlerData.FromCenterCtrl, Crosshairs.FromCenter);
709+
710+ HandlerData.LengthCtrl = GetCtrlFromWindow(Window(), 0, Length_Item);
711+ SetShort(HandlerData.LengthCtrl, Crosshairs.Length);
712+
713+ HandlerData.OpacityCtrl = GetCtrlFromWindow(Window(), 0, CH_Opacity_Item);
714+ SetFloat(HandlerData.OpacityCtrl, Crosshairs.Opacity);
715+
716+ HandlerData.ShapeCtrl = GetCtrlFromWindow(Window(), 0, Shape_Item);
717+ SetControl32BitValue(HandlerData.ShapeCtrl, Crosshairs.Shape+1);
718+
719+ // For making the preview drawable
720+ AutoDrawability Drawability;
721+
722+ HandlerData.ShowCtrl = GetCtrlFromWindow(Window(), 0, Show_Item);
723+
724+ Drawability(HandlerData.ShowCtrl, PreviewDrawer);
725+
726+ bool IsOK = RunModalDialog(Window(), true, Configure_Crosshair_Handler, &HandlerData);
727+
728+ // Save the new color, in case we want it
729+ RGBColor Color = Crosshairs.Color;
730+
731+ // Pop old crosshair state
732+ Crosshairs_SetActive(OldCrosshairActive);
733+ Crosshairs = OldCrosshairs;
734+
735+ // After that popping, just in case that data is the data being currently edited
736+ if (IsOK)
737+ {
738+ GetShort(HandlerData.ThicknessCtrl, Crosshairs.Thickness);
739+
740+ GetShort(HandlerData.FromCenterCtrl, Crosshairs.FromCenter);
741+
742+ GetShort(HandlerData.LengthCtrl, Crosshairs.Length);
743+
744+ GetFloat(HandlerData.OpacityCtrl, Crosshairs.Opacity);
745+
746+ Crosshairs.Shape = GetControl32BitValue(HandlerData.ShapeCtrl) - 1;
747+
748+ Crosshairs.Color = Color;
749+ }
750+
751+ // Reset OpenGL precalculation
752+ Crosshairs.PreCalced = false;
753+
754+ return IsOK;
755+}
756+
757+
758+#else
759+
760+
761+// Procedure for displaying the preview
762+static pascal void DoPreview(DialogPtr Dialog, short ItemNo)
763+{
764+ // Get essential stuff on the item to receive the preview
765+ short ItemType;
766+ Rect Bounds;
767+ ControlHandle CHdl;
768+ GetDialogItem(Dialog, ItemNo, &ItemType, (Handle *)&CHdl, &Bounds);
769+
770+ // Push previous state
771+ PenState OldPen;
772+ RGBColor OldBackColor, OldForeColor;
773+
774+ GetPenState(&OldPen);
775+ GetBackColor(&OldBackColor);
776+ GetForeColor(&OldForeColor);
777+
778+ // Get ready to do the drawing
779+ PenNormal();
780+
781+ // Draw the background
782+ RGBForeColor(&BkgdColor);
783+ PaintRect(&Bounds);
784+
785+ // Push old crosshair state
786+ bool OldCrosshairState = Crosshairs_IsActive();
787+ Crosshairs_SetActive(true);
788+
789+ // Clip to inside of box
790+ ClipRect(&Bounds);
791+
792+ // Draw the crosshairs
793+ Crosshairs_Render(Bounds);
794+
795+ // No more clipping
796+ Rect portRect;
797+ GetPortBounds(GetWindowPort(GetDialogWindow(Dialog)), &portRect);
798+ ClipRect(&portRect);
799+
800+ // Pop old crosshair state
801+ Crosshairs_SetActive(OldCrosshairState);
802+
803+ // Draw the boundary line
804+ RGBForeColor(&rgb_black);
805+ FrameRect(&Bounds);
806+
807+ // Pop previous state
808+ SetPenState(&OldPen);
809+ RGBBackColor(&OldBackColor);
810+ RGBForeColor(&OldForeColor);
811+}
812+
813+
814+// True for OK, false for cancel
815+bool Configure_Crosshairs(CrosshairData &Data)
816+{
817+ short ItemType;
818+ Rect Bounds;
819+
820+ DialogPtr Dialog = myGetNewDialog(Crosshairs_Dialog, NULL, (WindowPtr)(-1), 0);
821+ assert(Dialog);
822+
823+ ControlHandle Thickness_CHdl;
824+ GetDialogItem(Dialog, Thickness_Item, &ItemType, (Handle *)&Thickness_CHdl, &Bounds);
825+ SetShort(Thickness_CHdl,Data.Thickness);
826+
827+ ControlHandle FromCenter_CHdl;
828+ GetDialogItem(Dialog, FromCenter_Item, &ItemType, (Handle *)&FromCenter_CHdl, &Bounds);
829+ SetShort(FromCenter_CHdl,Data.FromCenter);
830+
831+ ControlHandle Length_CHdl;
832+ GetDialogItem(Dialog, Length_Item, &ItemType, (Handle *)&Length_CHdl, &Bounds);
833+ SetShort(Length_CHdl,Data.Length);
834+
835+ ControlHandle Shape_CHdl;
836+ GetDialogItem(Dialog, Shape_Item, &ItemType, (Handle *)&Shape_CHdl, &Bounds);
837+ SetControlValue(Shape_CHdl,Data.Shape+1);
838+
839+ ControlHandle Opacity_CHdl;
840+ GetDialogItem(Dialog, CH_Opacity_Item, &ItemType, (Handle *)&Opacity_CHdl, &Bounds);
841+ SetFloat(Opacity_CHdl,Data.Opacity);
842+
843+ // Create a UPP for the crosshair preview and store it
844+ UserItemUPP DoPreviewUPP = NewUserItemUPP(DoPreview);
845+ ControlHandle Show_CHdl;
846+ GetDialogItem(Dialog, Show_Item, &ItemType, (Handle *)&Show_CHdl, &Bounds);
847+ SetDialogItem(Dialog, Show_Item, ItemType, Handle(DoPreviewUPP), &Bounds);
848+
849+ // Where to make the color picker
850+ Point Center = {-1,-1};
851+
852+ // Remembering the old values is necessary for the preview to work properly
853+ CrosshairData SavedData = Data;
854+
855+ // Reveal it
856+#if USE_SHEETS
857+ SetThemeWindowBackground(GetDialogWindow(Dialog), kThemeBrushSheetBackgroundTransparent, false);
858+ ShowSheetWindow(GetDialogWindow(Dialog), ActiveNonFloatingWindow());
859+#else
860+ SelectWindow(GetDialogWindow(Dialog));
861+ ShowWindow(GetDialogWindow(Dialog));
862+#endif
863+
864+ bool WillQuit = false;
865+ bool IsOK = false;
866+ short ShortTemp;
867+ float FloatTemp;
868+ RGBColor NewColor;
869+ bool BadValue, OverallBadValue;
870+ while(!WillQuit)
871+ {
872+ short ItemHit;
873+ ModalDialog(NULL, &ItemHit);
874+
875+ switch(ItemHit)
876+ {
877+ case OK_Item:
878+ case Preview_Item:
879+ // Check before quitting or redrawing;
880+ OverallBadValue = false;
881+
882+ BadValue = false;
883+ if (GetShort(Thickness_CHdl,ShortTemp))
884+ {
885+ if (ShortTemp > 0)
886+ Data.Thickness = ShortTemp;
887+ else
888+ BadValue = true;
889+ } else
890+ BadValue = true;
891+
892+ if (BadValue)
893+ {
894+ SetShort(Thickness_CHdl,Data.Thickness);
895+ OverallBadValue = true;
896+ }
897+
898+ BadValue = false;
899+ if (GetShort(FromCenter_CHdl,ShortTemp))
900+ {
901+ if (ShortTemp >= 0)
902+ Data.FromCenter = ShortTemp;
903+ else
904+ BadValue = true;
905+ } else
906+ BadValue = true;
907+
908+ if (BadValue)
909+ {
910+ SetShort(FromCenter_CHdl,Data.FromCenter);
911+ OverallBadValue = true;
912+ }
913+
914+ BadValue = false;
915+ if (GetShort(Length_CHdl,ShortTemp))
916+ {
917+ if (ShortTemp > 0)
918+ Data.Length = ShortTemp;
919+ else
920+ BadValue = true;
921+ } else
922+ BadValue = true;
923+
924+ if (BadValue)
925+ {
926+ SetShort(Length_CHdl,Data.Length);
927+ OverallBadValue = true;
928+ }
929+
930+ BadValue = false;
931+ if (GetFloat(Opacity_CHdl,FloatTemp))
932+ {
933+ if (FloatTemp >= 0 && FloatTemp <= 1)
934+ Data.Opacity = FloatTemp;
935+ else
936+ BadValue = true;
937+ } else
938+ BadValue = true;
939+
940+ if (BadValue)
941+ {
942+ SetFloat(Opacity_CHdl,Data.Opacity);
943+ OverallBadValue = true;
944+ }
945+
946+ Data.Shape = GetControlValue(Shape_CHdl)-1;
947+
948+ if (OverallBadValue)
949+ {
950+ SysBeep(30);
951+ DrawDialog(Dialog); // To do the reversion correctly
952+ break;
953+ }
954+
955+ switch(ItemHit)
956+ {
957+ case Preview_Item:
958+ DrawDialog(Dialog);
959+ break;
960+
961+ case OK_Item:
962+ IsOK = true;
963+ WillQuit = true;
964+ break;
965+ }
966+ break;
967+
968+ case Cancel_Item:
969+ IsOK = false;
970+ WillQuit = true;
971+ break;
972+
973+ case GetColor_Item:
974+ // Need to set color here so the preview can work properly
975+ if (GetColor(Center,"\pWhat crosshair color?",&Data.Color,&NewColor))
976+ Data.Color = NewColor;
977+ DrawDialog(Dialog);
978+ break;
979+
980+ case BkgdColor_Item:
981+ if (GetColor(Center,"\pWhat preview background color?",&BkgdColor,&NewColor))
982+ BkgdColor = NewColor;
983+ DrawDialog(Dialog);
984+ break;
985+ }
986+ }
987+
988+ if (!IsOK)
989+ {
990+ // Revert all these values
991+ Data = SavedData;
992+ }
993+
994+ // Clean up
995+#if USE_SHEETS
996+ HideSheetWindow(GetDialogWindow(Dialog));
997+#else
998+ HideWindow(GetDialogWindow(Dialog));
999+#endif
1000+
1001+ DisposeUserItemUPP(DoPreviewUPP);
1002+ DisposeDialog(Dialog);
1003+
1004+ return IsOK;
1005+}
1006+
1007+#endif
--- marathon/trunk/Source_Files/Misc/macintosh_network.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/macintosh_network.h (revision 526)
@@ -1,159 +1,159 @@
1-#ifndef __MACINTOSH__NETWORK_H
2-#define __MACINTOSH__NETWORK_H
3-
4-/*
5-MACINTOSH_NETWORK.H
6-
7- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8- and the "Aleph One" developers.
9-
10- This program is free software; you can redistribute it and/or modify
11- it under the terms of the GNU General Public License as published by
12- the Free Software Foundation; either version 3 of the License, or
13- (at your option) any later version.
14-
15- This program is distributed in the hope that it will be useful,
16- but WITHOUT ANY WARRANTY; without even the implied warranty of
17- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18- GNU General Public License for more details.
19-
20- This license is contained in the file "COPYING",
21- which is included with this source code; it is available online at
22- http://www.gnu.org/licenses/gpl.html
23-
24-Monday, June 20, 1994 12:22:25 PM
25-Wednesday, August 9, 1995 3:34:50 PM- network lookup stuff now takes a version which is
26- concatenated to the lookup type (ryan)
27-
28-Jan 25, 2002 (Br'fin (Jeremy Parsons)):
29- Disabled networking under carbon
30-*/
31-
32-#if defined(TARGET_API_MAC_CARBON)
33-#warning Classic Appletalk networking not supported under carbon
34-#endif
35-
36-#include <AppleTalk.h>
37-#include <ADSP.h>
38-
39-#include "network.h"
40-
41-/* ---------- constants */
42-
43-/* missing from AppleTalk.h */
44-#define ddpMaxData 586
45-
46-/* ---------- DDPFrame and PacketBuffer (DDP) */
47-
48-struct DDPFrame
49-{
50- short data_size;
51- byte data[ddpMaxData];
52-
53- MPPParamBlock pb;
54-
55- WDSElement wds[3];
56- byte header[17];
57-};
58-typedef struct DDPFrame DDPFrame, *DDPFramePtr;
59-
60-struct DDPPacketBuffer
61-{
62- short inUse;
63-
64- byte protocolType;
65- byte destinationNode;
66- AddrBlock sourceAddress;
67- short hops;
68-
69- short datagramSize;
70- byte datagramData[ddpMaxData];
71-};
72-typedef struct DDPPacketBuffer DDPPacketBuffer, *DDPPacketBufferPtr;
73-
74-/* ---------- ConnectionEnd (ADSP) */
75-
76-struct ConnectionEnd
77-{
78- short ccbRefNum, socketNum; /* reference number and socket number of this connection end */
79-
80- /* memory for ADSP */
81- TPCCB dspCCB;
82- Ptr dspSendQPtr;
83- Ptr dspRecvQPtr;
84- Ptr dspAttnBufPtr;
85-
86-#ifdef env68k
87- long a5; /* store our current a5 here */
88-#endif
89-
90- DSPParamBlock pb; /* parameter block for this connection end */
91-};
92-typedef struct ConnectionEnd ConnectionEnd, *ConnectionEndPtr;
93-
94-/* ---------- types */
95-
96-typedef EntityName *EntityNamePtr;
97-
98-typedef void (*lookupUpdateProcPtr)(short message, short index);
99-typedef bool (*lookupFilterProcPtr)(EntityName *entity, AddrBlock *address);
100-typedef void (*PacketHandlerProcPtr)(DDPPacketBufferPtr packet);
101-#ifdef env68k
102-typedef PacketHandlerProcPtr PacketHandlerUPP;
103-#else
104-typedef UniversalProcPtr PacketHandlerUPP;
105-#endif
106-typedef DDPSocketListenerUPP (*InitializeListenerProcPtr)(
107- PacketHandlerUPP handler,
108- DDPPacketBufferPtr buffer);
109-#ifdef env68k
110-typedef InitializeListenerProcPtr InitializeListenerUPP;
111-#else
112-typedef UniversalProcPtr InitializeListenerUPP;
113-#endif
114-
115-/* ---------- prototypes/NETWORK.C */
116-
117-short NetState(void);
118-
119-void NetSetServerIdentifier(short identifier);
120-
121-/* for giving to NetLookupOpen() as a filter procedure */
122-bool NetEntityNotInGame(EntityName *entity, AddrBlock *address);
123-
124-/* ---------- prototypes/NETWORK_NAMES.C */
125-
126-OSErr NetRegisterName(unsigned char *name, unsigned char *type, short version, short socketNumber);
127-OSErr NetUnRegisterName(void);
128-
129-/* ---------- prototypes/NETWORK_LOOKUP.C */
130-
131-void NetLookupUpdate(void);
132-void NetLookupClose(void);
133-OSErr NetLookupOpen(unsigned char *name, unsigned char *type, unsigned char *zone, short version,
134- lookupUpdateProcPtr updateProc, lookupFilterProcPtr filterProc);
135-void NetLookupRemove(short index);
136-void NetLookupInformation(short index, AddrBlock *address, EntityName *entity);
137-
138-OSErr NetGetZonePopupMenu(MenuHandle menu, short *local_zone);
139-OSErr NetGetZoneList(Str32 *zone_names, short maximum_zone_names, short *zone_count, short *local_zone);
140-OSErr NetGetLocalZoneName(Str32 local_zone_name);
141-
142-/* ---------- prototypes/NETWORK_DDP.C */
143-
144-OSErr NetDDPOpen(void);
145-OSErr NetDDPClose(void);
146-
147-OSErr NetDDPOpenSocket(short *socketNumber, PacketHandlerProcPtr packetHandler);
148-OSErr NetDDPCloseSocket(short socketNumber);
149-
150-DDPFramePtr NetDDPNewFrame(void);
151-void NetDDPDisposeFrame(DDPFramePtr frame);
152-
153-OSErr NetDDPSendFrame(DDPFramePtr frame, AddrBlock *address, short protocolType, short socket);
154-
155-/* ---------- prototypes/NETWORK_ADSP.C */
156-
157-// jkvw: removed - we use TCPMess now
158-
159-#endif
1+#ifndef __MACINTOSH__NETWORK_H
2+#define __MACINTOSH__NETWORK_H
3+
4+/*
5+MACINTOSH_NETWORK.H
6+
7+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8+ and the "Aleph One" developers.
9+
10+ This program is free software; you can redistribute it and/or modify
11+ it under the terms of the GNU General Public License as published by
12+ the Free Software Foundation; either version 3 of the License, or
13+ (at your option) any later version.
14+
15+ This program is distributed in the hope that it will be useful,
16+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+ GNU General Public License for more details.
19+
20+ This license is contained in the file "COPYING",
21+ which is included with this source code; it is available online at
22+ http://www.gnu.org/licenses/gpl.html
23+
24+Monday, June 20, 1994 12:22:25 PM
25+Wednesday, August 9, 1995 3:34:50 PM- network lookup stuff now takes a version which is
26+ concatenated to the lookup type (ryan)
27+
28+Jan 25, 2002 (Br'fin (Jeremy Parsons)):
29+ Disabled networking under carbon
30+*/
31+
32+#if defined(TARGET_API_MAC_CARBON)
33+#warning Classic Appletalk networking not supported under carbon
34+#endif
35+
36+#include <AppleTalk.h>
37+#include <ADSP.h>
38+
39+#include "network.h"
40+
41+/* ---------- constants */
42+
43+/* missing from AppleTalk.h */
44+#define ddpMaxData 586
45+
46+/* ---------- DDPFrame and PacketBuffer (DDP) */
47+
48+struct DDPFrame
49+{
50+ short data_size;
51+ byte data[ddpMaxData];
52+
53+ MPPParamBlock pb;
54+
55+ WDSElement wds[3];
56+ byte header[17];
57+};
58+typedef struct DDPFrame DDPFrame, *DDPFramePtr;
59+
60+struct DDPPacketBuffer
61+{
62+ short inUse;
63+
64+ byte protocolType;
65+ byte destinationNode;
66+ AddrBlock sourceAddress;
67+ short hops;
68+
69+ short datagramSize;
70+ byte datagramData[ddpMaxData];
71+};
72+typedef struct DDPPacketBuffer DDPPacketBuffer, *DDPPacketBufferPtr;
73+
74+/* ---------- ConnectionEnd (ADSP) */
75+
76+struct ConnectionEnd
77+{
78+ short ccbRefNum, socketNum; /* reference number and socket number of this connection end */
79+
80+ /* memory for ADSP */
81+ TPCCB dspCCB;
82+ Ptr dspSendQPtr;
83+ Ptr dspRecvQPtr;
84+ Ptr dspAttnBufPtr;
85+
86+#ifdef env68k
87+ long a5; /* store our current a5 here */
88+#endif
89+
90+ DSPParamBlock pb; /* parameter block for this connection end */
91+};
92+typedef struct ConnectionEnd ConnectionEnd, *ConnectionEndPtr;
93+
94+/* ---------- types */
95+
96+typedef EntityName *EntityNamePtr;
97+
98+typedef void (*lookupUpdateProcPtr)(short message, short index);
99+typedef bool (*lookupFilterProcPtr)(EntityName *entity, AddrBlock *address);
100+typedef void (*PacketHandlerProcPtr)(DDPPacketBufferPtr packet);
101+#ifdef env68k
102+typedef PacketHandlerProcPtr PacketHandlerUPP;
103+#else
104+typedef UniversalProcPtr PacketHandlerUPP;
105+#endif
106+typedef DDPSocketListenerUPP (*InitializeListenerProcPtr)(
107+ PacketHandlerUPP handler,
108+ DDPPacketBufferPtr buffer);
109+#ifdef env68k
110+typedef InitializeListenerProcPtr InitializeListenerUPP;
111+#else
112+typedef UniversalProcPtr InitializeListenerUPP;
113+#endif
114+
115+/* ---------- prototypes/NETWORK.C */
116+
117+short NetState(void);
118+
119+void NetSetServerIdentifier(short identifier);
120+
121+/* for giving to NetLookupOpen() as a filter procedure */
122+bool NetEntityNotInGame(EntityName *entity, AddrBlock *address);
123+
124+/* ---------- prototypes/NETWORK_NAMES.C */
125+
126+OSErr NetRegisterName(unsigned char *name, unsigned char *type, short version, short socketNumber);
127+OSErr NetUnRegisterName(void);
128+
129+/* ---------- prototypes/NETWORK_LOOKUP.C */
130+
131+void NetLookupUpdate(void);
132+void NetLookupClose(void);
133+OSErr NetLookupOpen(unsigned char *name, unsigned char *type, unsigned char *zone, short version,
134+ lookupUpdateProcPtr updateProc, lookupFilterProcPtr filterProc);
135+void NetLookupRemove(short index);
136+void NetLookupInformation(short index, AddrBlock *address, EntityName *entity);
137+
138+OSErr NetGetZonePopupMenu(MenuHandle menu, short *local_zone);
139+OSErr NetGetZoneList(Str32 *zone_names, short maximum_zone_names, short *zone_count, short *local_zone);
140+OSErr NetGetLocalZoneName(Str32 local_zone_name);
141+
142+/* ---------- prototypes/NETWORK_DDP.C */
143+
144+OSErr NetDDPOpen(void);
145+OSErr NetDDPClose(void);
146+
147+OSErr NetDDPOpenSocket(short *socketNumber, PacketHandlerProcPtr packetHandler);
148+OSErr NetDDPCloseSocket(short socketNumber);
149+
150+DDPFramePtr NetDDPNewFrame(void);
151+void NetDDPDisposeFrame(DDPFramePtr frame);
152+
153+OSErr NetDDPSendFrame(DDPFramePtr frame, AddrBlock *address, short protocolType, short socket);
154+
155+/* ---------- prototypes/NETWORK_ADSP.C */
156+
157+// jkvw: removed - we use TCPMess now
158+
159+#endif
--- marathon/trunk/Source_Files/Misc/interface.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/interface.h (revision 526)
@@ -1,463 +1,463 @@
1-#ifndef __INTERFACE_H
2-#define __INTERFACE_H
3-
4-/*
5-INTERFACE.H
6-
7- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8- and the "Aleph One" developers.
9-
10- This program is free software; you can redistribute it and/or modify
11- it under the terms of the GNU General Public License as published by
12- the Free Software Foundation; either version 3 of the License, or
13- (at your option) any later version.
14-
15- This program is distributed in the hope that it will be useful,
16- but WITHOUT ANY WARRANTY; without even the implied warranty of
17- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18- GNU General Public License for more details.
19-
20- This license is contained in the file "COPYING",
21- which is included with this source code; it is available online at
22- http://www.gnu.org/licenses/gpl.html
23-
24-Monday, August 23, 1993 4:35:53 PM
25-
26-Feb 24, 2000 (Loren Petrich):
27- Added get_number_of_collection_frames(), so as to assist in wall-texture error checking
28-
29-Feb 25, 2000 (Loren Petrich):
30- Added chase-cam and crosshair data structures and dialogs
31-
32-Mar 2, 2000 (Loren Petrich):
33- Moved the chase-cam and crosshair stuff out to ChaseCam.h and Crosshairs.h
34-
35-Mar 22, 2000 (Loren Petrich):
36- Added ResetFieldOfView(), a function that sets the field of view to the player's current state
37- (if extravision is active, then extravision, otherwise normal). It's defined in screen.c
38-
39-Apr 27, 2000 (Loren Petrich):
40- Added Josh Elsasser's "don't switch weapons" patch
41-
42-Apr 30, 2000 (Loren Petrich):
43- Added reloading of view context when reverting, so that OpenGL won't look funny when one
44- changes a level.
45-
46-May 1, 2000 (Loren Petrich): Added XML parser object for the infravision stuff.
47-
48-May 16, 2000 (Loren Petrich): Added XML parser for the control panels
49-
50-May 16, 2002 (Woody Zenfell):
51- Interfaces to dont_auto_recenter and to routines to help make such modifications safer
52- for films and netplay.
53-*/
54-
55-#include "XML_ElementParser.h"
56-
57-class FileSpecifier;
58-
59-/* ---------- constants */
60-
61-#define strFILENAMES 129
62-enum /* filenames in strFILENAMES */
63-{
64- filenameSHAPES8,
65- filenameSHAPES16,
66- filenameSOUNDS8,
67- filenameSOUNDS16,
68- filenamePREFERENCES,
69- filenameDEFAULT_MAP,
70- filenameDEFAULT_SAVE_GAME,
71- filenameMARATHON_NAME,
72- filenameMARATHON_RECORDING,
73- filenamePHYSICS_MODEL,
74- filenameMUSIC,
75- filenameIMAGES,
76- filenameMOVIE,
77- filenameDEFAULT_THEME
78-};
79-
80-#define strPATHS 138
81-
82-#define strERRORS 128
83-enum /* errors in strERRORS */
84-{
85- badProcessor= 0,
86- badQuickDraw,
87- badSystem,
88- badMemory,
89- badMonitor,
90- badExtraFileLocations,
91- badSoundChannels,
92- fileError,
93- copyHasBeenModified, // bad serial number
94- copyHasExpired,
95- keyIsUsedForSound,
96- keyIsUsedForMapZooming,
97- keyIsUsedForScrolling,
98- keyIsUsedAlready,
99- outOfMemory,
100- warningExternalPhysicsModel,
101- warningExternalMapsFile,
102- badReadMapGameError,
103- badReadMapSystemError,
104- badWriteMap,
105- badSerialNumber,
106- duplicateSerialNumbers,
107- networkOnlySerialNumber,
108- corruptedMap,
109- checkpointNotFound,
110- pictureNotFound,
111- networkNotSupportedForDemo,
112- serverQuitInCooperativeNetGame,
113- unableToGracefullyChangeLevelsNet,
114- cantFindMap, // called when the save game can't find the map. Reverts to default map.
115- cantFindReplayMap, // called when you can't find the map that the replay references..
116- notEnoughNetworkMemory,
117- luascriptconflict,
118- replayVersionTooNew,
119- keyScrollWheelDoesntWork
120-};
121-
122-enum /* animation types */
123-{
124- _animated1= 1,
125- _animated2to8= 2, /* ?? */
126- _animated3to4= 3,
127- _animated4= 4,
128- _animated5to8= 5,
129- _animated8= 8,
130- _animated3to5= 9,
131- _unanimated= 10,
132- _animated5= 11
133-};
134-
135-enum /* shading tables */
136-{
137- _darkening_table
138-};
139-
140-enum /* shape types (this is for the editor) */
141-{
142- _wall_shape, /* things designated as walls */
143- _floor_or_ceiling_shape, /* walls in raw format */
144- _object_shape, /* things designated as objects */
145- _other_shape /* anything not falling into the above categories (guns, interface elements, etc) */
146-};
147-
148-#define TOTAL_SHAPE_COLLECTIONS 128
149-
150-enum /* The various default key setups a user can select. for vbl.c and it's callers */
151-{
152- _standard_keyboard_setup,
153- _left_handed_keyboard_setup,
154- _powerbook_keyboard_setup,
155- NUMBER_OF_KEY_SETUPS,
156-
157- _custom_keyboard_setup = NONE
158-};
159-
160-#define INDEFINATE_TIME_DELAY (INT32_MAX)
161-
162-/* ---------- shape descriptors */
163-
164-#include "shape_descriptors.h"
165-
166-/* ---------- structures */
167-
168-#define _X_MIRRORED_BIT 0x8000
169-#define _Y_MIRRORED_BIT 0x4000
170-#define _KEYPOINT_OBSCURED_BIT 0x2000
171-
172-struct shape_information_data
173-{
174- uint16 flags; /* [x-mirror.1] [y-mirror.1] [keypoint_obscured.1] [unused.13] */
175-
176- _fixed minimum_light_intensity; /* in [0,FIXED_ONE] */
177-
178- short unused[5];
179-
180- short world_left, world_right, world_top, world_bottom;
181- short world_x0, world_y0;
182-};
183-
184-struct shape_animation_data // Also used in high_level_shape_definition
185-{
186- int16 number_of_views; /* must be 1, 2, 5 or 8 */
187-
188- int16 frames_per_view, ticks_per_frame;
189- int16 key_frame;
190-
191- int16 transfer_mode;
192- int16 transfer_mode_period; /* in ticks */
193-
194- int16 first_frame_sound, key_frame_sound, last_frame_sound;
195-
196- int16 pixels_to_world;
197-
198- int16 loop_frame;
199-
200- int16 unused[14];
201-
202- /* N*frames_per_view indexes of low-level shapes follow, where
203- N = 1 if number_of_views = _unanimated/_animated1,
204- N = 4 if number_of_views = _animated3to4/_animated4,
205- N = 5 if number_of_views = _animated3to5/_animated5,
206- N = 8 if number_of_views = _animated2to8/_animated5to8/_animated8 */
207- int16 low_level_shape_indexes[1];
208-};
209-
210-/* ---------- prototypes/SHELL.C */
211-
212-enum { /* controllers */
213- _single_player,
214- _network_player,
215- _demo,
216- _replay,
217- _replay_from_file,
218- NUMBER_OF_PSEUDO_PLAYERS
219-};
220-
221-enum { /* states. */
222- _display_intro_screens,
223- _display_main_menu,
224- _display_chapter_heading,
225- _display_prologue,
226- _display_epilogue,
227- _display_credits,
228- _display_intro_screens_for_demo,
229- _display_quit_screens,
230- NUMBER_OF_SCREENS,
231- _game_in_progress= NUMBER_OF_SCREENS,
232- _quit_game,
233- _close_game,
234- _switch_demo,
235- _revert_game,
236- _change_level,
237- _begin_display_of_epilogue,
238- _displaying_network_game_dialogs,
239- NUMBER_OF_GAME_STATES
240-};
241-
242-bool game_window_is_full_screen(void);
243-void set_change_level_destination(short level_number);
244-bool networking_available(void);
245-void free_and_unlock_memory(void);
246-
247-/* ---------- prototypes/INTERFACE.C */
248-
249-void initialize_game_state(void);
250-void force_game_state_change(void);
251-bool player_controlling_game(void);
252-
253-void toggle_suppression_of_background_tasks(void);
254-bool suppress_background_events(void);
255-
256-void set_game_state(short new_state);
257-short get_game_state(void);
258-short get_game_controller(void);
259-bool current_netgame_allows_microphone();
260-void set_change_level_destination(short level_number);
261-bool check_level_change(void);
262-void pause_game(void);
263-void resume_game(void);
264-void portable_process_screen_click(short x, short y, bool cheatkeys_down);
265-void draw_menu_button_for_command(short index);
266-void update_interface_display(void);
267-bool idle_game_state(uint32 ticks);
268-void display_main_menu(void);
269-void do_menu_item_command(short menu_id, short menu_item, bool cheat);
270-bool interface_fade_finished(void);
271-void stop_interface_fade(void);
272-bool enabled_item(short item);
273-void paint_window_black(void);
274-
275-/* ---------- prototypes/INTERFACE_MACINTOSH.C */
276-void do_preferences(void);
277-short get_level_number_from_user(void);
278-void toggle_menus(bool game_started);
279-void install_network_microphone(void);
280-void remove_network_microphone(void);
281-
282-// Should return NONE if user cancels, 0 for single player, or 1 for multiplayer.
283-// Game has been loaded from file before this is called so elements like
284-// dynamic_world->player_count are available. Cursor has been hidden when called.
285-size_t should_restore_game_networked();
286-
287-void show_movie(short index);
288-
289-void exit_networking(void);
290-
291-void load_main_menu_buffers(short base_id);
292-bool main_menu_buffers_loaded(void);
293-void main_menu_bit_depth_changed(short base_id);
294-void free_main_menu_buffers(void);
295-void draw_main_menu(void);
296-void draw_menu_button(short index, bool pressed);
297-
298-/* ---------- prototypes/INTERFACE_MACINTOSH.C- couldn't think of a better place... */
299-void hide_cursor(void);
300-void show_cursor(void);
301-bool mouse_still_down(void);
302-void get_mouse_position(short *x, short *y);
303-void set_drawing_clip_rectangle(short top, short left, short bottom, short right);
304-
305-/* ---------- prototypes/SHAPES.C */
306-void *get_global_shading_table(void);
307-
308-short get_shape_descriptors(short shape_type, shape_descriptor *buffer);
309-
310-#define get_shape_bitmap_and_shading_table(shape, bitmap, shading_table, shading_mode) extended_get_shape_bitmap_and_shading_table(GET_DESCRIPTOR_COLLECTION(shape), \
311- GET_DESCRIPTOR_SHAPE(shape), (bitmap), (shading_table), (shading_mode))
312-void extended_get_shape_bitmap_and_shading_table(short collection_code, short low_level_shape_index,
313- struct bitmap_definition **bitmap, void **shading_tables, short shading_mode);
314-
315-#define get_shape_information(shape) extended_get_shape_information(GET_DESCRIPTOR_COLLECTION(shape), GET_DESCRIPTOR_SHAPE(shape))
316-struct shape_information_data *extended_get_shape_information(short collection_code, short low_level_shape_index);
317-
318-void get_shape_hotpoint(shape_descriptor texture, short *x0, short *y0);
319-struct shape_animation_data *get_shape_animation_data(shape_descriptor texture);
320-void process_collection_sounds(short colleciton_code, void (*process_sound)(short sound_index));
321-
322-#define mark_collection_for_loading(c) mark_collection((c), true)
323-#define mark_collection_for_unloading(c) mark_collection((c), false)
324-void mark_collection(short collection_code, bool loading);
325-void strip_collection(short collection_code);
326-void load_collections(bool with_progress_bar, bool is_opengl);
327-int count_replacement_collections();
328-void load_replacement_collections();
329-void unload_all_collections(void);
330-
331-void set_shapes_patch_data(uint8 *data, size_t length);
332-uint8* get_shapes_patch_data(size_t &length);
333-
334-// LP additions:
335-// Whether or not collection is present
336-bool is_collection_present(short collection_index);
337-// Number of texture frames in a collection (good for wall-texture error checking)
338-short get_number_of_collection_frames(short collection_index);
339-// Number of bitmaps in a collection (good for allocating texture information for OpenGL)
340-short get_number_of_collection_bitmaps(short collection_index);
341-// Which bitmap index for a frame (good for OpenGL texture rendering)
342-short get_bitmap_index(short collection_index, short low_level_shape_index);
343-// Get CLUT for collection
344-struct rgb_color_value *get_collection_colors(short collection_index, short clut_number, int &num_colors);
345-
346-// ZZZ: made these visible
347-struct low_level_shape_definition *get_low_level_shape_definition(short collection_index, short low_level_shape_index);
348-
349-
350-/* ---------- prototypes/PREPROCESS_MAP_MAC.C */
351-void setup_revert_game_info(struct game_data *game_info, struct player_start_data *start, struct entry_point *entry);
352-bool revert_game(void);
353-bool load_game(bool use_last_load);
354-bool save_game(void);
355-bool save_game_full_auto(bool inOverwriteRecent);
356-void restart_game(void);
357-
358-/* ---------- prototypes/GAME_WAD.C */
359-/* Map transferring fuctions */
360-int32 get_net_map_data_length(void *data);
361-bool process_net_map_data(void *data); /* Note that this frees it as well */
362-void *get_map_for_net_transfer(struct entry_point *entry);
363-
364-/* ---------- prototypes/VBL.C */
365-
366-void set_keyboard_controller_status(bool active);
367-bool get_keyboard_controller_status(void);
368-void pause_keyboard_controller(bool active);
369-int32 get_heartbeat_count(void);
370-void sync_heartbeat_count(void);
371-void process_action_flags(short player_identifier, const uint32 *action_flags, short count);
372-void rewind_recording(void);
373-void stop_recording(void);
374-void stop_replay(void);
375-void move_replay(void);
376-void check_recording_replaying(void);
377-short find_key_setup(short *keycodes);
378-void set_default_keys(short *keycodes, short which_default);
379-void set_keys(short *keycodes);
380-bool has_recording_file(void);
381-void increment_replay_speed(void);
382-void decrement_replay_speed(void);
383-void reset_recording_and_playback_queues(void);
384-uint32 parse_keymap(void);
385-
386-/* ---------- prototypes/GAME_DIALOGS.C */
387-
388-bool handle_preferences_dialog(void);
389-void handle_load_game(void);
390-void handle_save_game(void);
391-bool handle_start_game(void);
392-bool quit_without_saving(void);
393-
394-/* ---------- prototypes/GAME_WINDOW.C */
395-void scroll_inventory(short dy);
396-
397-/* ---------- prototypes/NETWORK.C */
398-
399-enum { // Results for network_join
400- kNetworkJoinFailedUnjoined,
401- kNetworkJoinFailedJoined,
402- kNetworkJoinedNewGame,
403- kNetworkJoinedResumeGame
404-};
405-
406-bool network_gather(bool inResumingGame);
407-int network_join(void);
408-
409-/* ---------- prototypes/NETWORK_MICROPHONE.C */
410-
411-void handle_microphone(bool triggered);
412-
413-/* ---------- prototypes/PHYSICS.C */
414-
415-void reset_absolute_positioning_device(_fixed yaw, _fixed pitch, _fixed velocity);
416-
417-/* ---------- prototypes/IMPORT_DEFINITIONS.C */
418-
419-void init_physics_wad_data();
420-void import_definition_structures(void);
421-
422-/* ---------- prototypes/KEYBOARD_DIALOG.C */
423-bool configure_key_setup(short *keycodes);
424-
425-/* --------- from PREPROCESS_MAP_MAC.C */
426-bool have_default_files(void);
427-void get_default_map_spec(FileSpecifier& File);
428-void get_default_physics_spec(FileSpecifier& File);
429-void get_default_sounds_spec(FileSpecifier& File);
430-void get_default_shapes_spec(FileSpecifier& File);
431-bool get_default_theme_spec(FileSpecifier& File);
432-// ZZZ addition: since Mac versions now search for any candidate files instead of picking
433-// by name, new interface to search for all simultaneously instead of duplicating effort.
434-void get_default_file_specs(FileSpecifier* outMapSpec, FileSpecifier* outShapesSpec, FileSpecifier* outSoundsSpec, FileSpecifier* outPhysicsSpec);
435-
436-// LP change: resets field of view to whatever the player had had when reviving
437-void ResetFieldOfView();
438-
439-// LP change: modification of Josh Elsasser's dont-switch-weapons patch
440-bool dont_switch_to_new_weapon();
441-
442-// ZZZ: corresponds with dont_switch_to_new_weapon()
443-bool dont_auto_recenter();
444-
445-// ZZZ: let code disable (standardize)/enable behavior modifiers like
446-// dont_switch and dont_auto_recenter
447-void standardize_player_behavior_modifiers();
448-void restore_custom_player_behavior_modifiers();
449-
450-// ZZZ: return whether the user's behavior matches standard behavior
451-// (either by being forced so or by chosen that way)
452-bool is_player_behavior_standard();
453-
454-// LP change: force reload of view context
455-void ReloadViewContext();
456-
457-// LP change: added infravision-parser export
458-XML_ElementParser *Infravision_GetParser();
459-
460-// LP change: added control-panel-parser export
461-XML_ElementParser *ControlPanels_GetParser();
462-
463-#endif
1+#ifndef __INTERFACE_H
2+#define __INTERFACE_H
3+
4+/*
5+INTERFACE.H
6+
7+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8+ and the "Aleph One" developers.
9+
10+ This program is free software; you can redistribute it and/or modify
11+ it under the terms of the GNU General Public License as published by
12+ the Free Software Foundation; either version 3 of the License, or
13+ (at your option) any later version.
14+
15+ This program is distributed in the hope that it will be useful,
16+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+ GNU General Public License for more details.
19+
20+ This license is contained in the file "COPYING",
21+ which is included with this source code; it is available online at
22+ http://www.gnu.org/licenses/gpl.html
23+
24+Monday, August 23, 1993 4:35:53 PM
25+
26+Feb 24, 2000 (Loren Petrich):
27+ Added get_number_of_collection_frames(), so as to assist in wall-texture error checking
28+
29+Feb 25, 2000 (Loren Petrich):
30+ Added chase-cam and crosshair data structures and dialogs
31+
32+Mar 2, 2000 (Loren Petrich):
33+ Moved the chase-cam and crosshair stuff out to ChaseCam.h and Crosshairs.h
34+
35+Mar 22, 2000 (Loren Petrich):
36+ Added ResetFieldOfView(), a function that sets the field of view to the player's current state
37+ (if extravision is active, then extravision, otherwise normal). It's defined in screen.c
38+
39+Apr 27, 2000 (Loren Petrich):
40+ Added Josh Elsasser's "don't switch weapons" patch
41+
42+Apr 30, 2000 (Loren Petrich):
43+ Added reloading of view context when reverting, so that OpenGL won't look funny when one
44+ changes a level.
45+
46+May 1, 2000 (Loren Petrich): Added XML parser object for the infravision stuff.
47+
48+May 16, 2000 (Loren Petrich): Added XML parser for the control panels
49+
50+May 16, 2002 (Woody Zenfell):
51+ Interfaces to dont_auto_recenter and to routines to help make such modifications safer
52+ for films and netplay.
53+*/
54+
55+#include "XML_ElementParser.h"
56+
57+class FileSpecifier;
58+
59+/* ---------- constants */
60+
61+#define strFILENAMES 129
62+enum /* filenames in strFILENAMES */
63+{
64+ filenameSHAPES8,
65+ filenameSHAPES16,
66+ filenameSOUNDS8,
67+ filenameSOUNDS16,
68+ filenamePREFERENCES,
69+ filenameDEFAULT_MAP,
70+ filenameDEFAULT_SAVE_GAME,
71+ filenameMARATHON_NAME,
72+ filenameMARATHON_RECORDING,
73+ filenamePHYSICS_MODEL,
74+ filenameMUSIC,
75+ filenameIMAGES,
76+ filenameMOVIE,
77+ filenameDEFAULT_THEME
78+};
79+
80+#define strPATHS 138
81+
82+#define strERRORS 128
83+enum /* errors in strERRORS */
84+{
85+ badProcessor= 0,
86+ badQuickDraw,
87+ badSystem,
88+ badMemory,
89+ badMonitor,
90+ badExtraFileLocations,
91+ badSoundChannels,
92+ fileError,
93+ copyHasBeenModified, // bad serial number
94+ copyHasExpired,
95+ keyIsUsedForSound,
96+ keyIsUsedForMapZooming,
97+ keyIsUsedForScrolling,
98+ keyIsUsedAlready,
99+ outOfMemory,
100+ warningExternalPhysicsModel,
101+ warningExternalMapsFile,
102+ badReadMapGameError,
103+ badReadMapSystemError,
104+ badWriteMap,
105+ badSerialNumber,
106+ duplicateSerialNumbers,
107+ networkOnlySerialNumber,
108+ corruptedMap,
109+ checkpointNotFound,
110+ pictureNotFound,
111+ networkNotSupportedForDemo,
112+ serverQuitInCooperativeNetGame,
113+ unableToGracefullyChangeLevelsNet,
114+ cantFindMap, // called when the save game can't find the map. Reverts to default map.
115+ cantFindReplayMap, // called when you can't find the map that the replay references..
116+ notEnoughNetworkMemory,
117+ luascriptconflict,
118+ replayVersionTooNew,
119+ keyScrollWheelDoesntWork
120+};
121+
122+enum /* animation types */
123+{
124+ _animated1= 1,
125+ _animated2to8= 2, /* ?? */
126+ _animated3to4= 3,
127+ _animated4= 4,
128+ _animated5to8= 5,
129+ _animated8= 8,
130+ _animated3to5= 9,
131+ _unanimated= 10,
132+ _animated5= 11
133+};
134+
135+enum /* shading tables */
136+{
137+ _darkening_table
138+};
139+
140+enum /* shape types (this is for the editor) */
141+{
142+ _wall_shape, /* things designated as walls */
143+ _floor_or_ceiling_shape, /* walls in raw format */
144+ _object_shape, /* things designated as objects */
145+ _other_shape /* anything not falling into the above categories (guns, interface elements, etc) */
146+};
147+
148+#define TOTAL_SHAPE_COLLECTIONS 128
149+
150+enum /* The various default key setups a user can select. for vbl.c and it's callers */
151+{
152+ _standard_keyboard_setup,
153+ _left_handed_keyboard_setup,
154+ _powerbook_keyboard_setup,
155+ NUMBER_OF_KEY_SETUPS,
156+
157+ _custom_keyboard_setup = NONE
158+};
159+
160+#define INDEFINATE_TIME_DELAY (INT32_MAX)
161+
162+/* ---------- shape descriptors */
163+
164+#include "shape_descriptors.h"
165+
166+/* ---------- structures */
167+
168+#define _X_MIRRORED_BIT 0x8000
169+#define _Y_MIRRORED_BIT 0x4000
170+#define _KEYPOINT_OBSCURED_BIT 0x2000
171+
172+struct shape_information_data
173+{
174+ uint16 flags; /* [x-mirror.1] [y-mirror.1] [keypoint_obscured.1] [unused.13] */
175+
176+ _fixed minimum_light_intensity; /* in [0,FIXED_ONE] */
177+
178+ short unused[5];
179+
180+ short world_left, world_right, world_top, world_bottom;
181+ short world_x0, world_y0;
182+};
183+
184+struct shape_animation_data // Also used in high_level_shape_definition
185+{
186+ int16 number_of_views; /* must be 1, 2, 5 or 8 */
187+
188+ int16 frames_per_view, ticks_per_frame;
189+ int16 key_frame;
190+
191+ int16 transfer_mode;
192+ int16 transfer_mode_period; /* in ticks */
193+
194+ int16 first_frame_sound, key_frame_sound, last_frame_sound;
195+
196+ int16 pixels_to_world;
197+
198+ int16 loop_frame;
199+
200+ int16 unused[14];
201+
202+ /* N*frames_per_view indexes of low-level shapes follow, where
203+ N = 1 if number_of_views = _unanimated/_animated1,
204+ N = 4 if number_of_views = _animated3to4/_animated4,
205+ N = 5 if number_of_views = _animated3to5/_animated5,
206+ N = 8 if number_of_views = _animated2to8/_animated5to8/_animated8 */
207+ int16 low_level_shape_indexes[1];
208+};
209+
210+/* ---------- prototypes/SHELL.C */
211+
212+enum { /* controllers */
213+ _single_player,
214+ _network_player,
215+ _demo,
216+ _replay,
217+ _replay_from_file,
218+ NUMBER_OF_PSEUDO_PLAYERS
219+};
220+
221+enum { /* states. */
222+ _display_intro_screens,
223+ _display_main_menu,
224+ _display_chapter_heading,
225+ _display_prologue,
226+ _display_epilogue,
227+ _display_credits,
228+ _display_intro_screens_for_demo,
229+ _display_quit_screens,
230+ NUMBER_OF_SCREENS,
231+ _game_in_progress= NUMBER_OF_SCREENS,
232+ _quit_game,
233+ _close_game,
234+ _switch_demo,
235+ _revert_game,
236+ _change_level,
237+ _begin_display_of_epilogue,
238+ _displaying_network_game_dialogs,
239+ NUMBER_OF_GAME_STATES
240+};
241+
242+bool game_window_is_full_screen(void);
243+void set_change_level_destination(short level_number);
244+bool networking_available(void);
245+void free_and_unlock_memory(void);
246+
247+/* ---------- prototypes/INTERFACE.C */
248+
249+void initialize_game_state(void);
250+void force_game_state_change(void);
251+bool player_controlling_game(void);
252+
253+void toggle_suppression_of_background_tasks(void);
254+bool suppress_background_events(void);
255+
256+void set_game_state(short new_state);
257+short get_game_state(void);
258+short get_game_controller(void);
259+bool current_netgame_allows_microphone();
260+void set_change_level_destination(short level_number);
261+bool check_level_change(void);
262+void pause_game(void);
263+void resume_game(void);
264+void portable_process_screen_click(short x, short y, bool cheatkeys_down);
265+void draw_menu_button_for_command(short index);
266+void update_interface_display(void);
267+bool idle_game_state(uint32 ticks);
268+void display_main_menu(void);
269+void do_menu_item_command(short menu_id, short menu_item, bool cheat);
270+bool interface_fade_finished(void);
271+void stop_interface_fade(void);
272+bool enabled_item(short item);
273+void paint_window_black(void);
274+
275+/* ---------- prototypes/INTERFACE_MACINTOSH.C */
276+void do_preferences(void);
277+short get_level_number_from_user(void);
278+void toggle_menus(bool game_started);
279+void install_network_microphone(void);
280+void remove_network_microphone(void);
281+
282+// Should return NONE if user cancels, 0 for single player, or 1 for multiplayer.
283+// Game has been loaded from file before this is called so elements like
284+// dynamic_world->player_count are available. Cursor has been hidden when called.
285+size_t should_restore_game_networked();
286+
287+void show_movie(short index);
288+
289+void exit_networking(void);
290+
291+void load_main_menu_buffers(short base_id);
292+bool main_menu_buffers_loaded(void);
293+void main_menu_bit_depth_changed(short base_id);
294+void free_main_menu_buffers(void);
295+void draw_main_menu(void);
296+void draw_menu_button(short index, bool pressed);
297+
298+/* ---------- prototypes/INTERFACE_MACINTOSH.C- couldn't think of a better place... */
299+void hide_cursor(void);
300+void show_cursor(void);
301+bool mouse_still_down(void);
302+void get_mouse_position(short *x, short *y);
303+void set_drawing_clip_rectangle(short top, short left, short bottom, short right);
304+
305+/* ---------- prototypes/SHAPES.C */
306+void *get_global_shading_table(void);
307+
308+short get_shape_descriptors(short shape_type, shape_descriptor *buffer);
309+
310+#define get_shape_bitmap_and_shading_table(shape, bitmap, shading_table, shading_mode) extended_get_shape_bitmap_and_shading_table(GET_DESCRIPTOR_COLLECTION(shape), \
311+ GET_DESCRIPTOR_SHAPE(shape), (bitmap), (shading_table), (shading_mode))
312+void extended_get_shape_bitmap_and_shading_table(short collection_code, short low_level_shape_index,
313+ struct bitmap_definition **bitmap, void **shading_tables, short shading_mode);
314+
315+#define get_shape_information(shape) extended_get_shape_information(GET_DESCRIPTOR_COLLECTION(shape), GET_DESCRIPTOR_SHAPE(shape))
316+struct shape_information_data *extended_get_shape_information(short collection_code, short low_level_shape_index);
317+
318+void get_shape_hotpoint(shape_descriptor texture, short *x0, short *y0);
319+struct shape_animation_data *get_shape_animation_data(shape_descriptor texture);
320+void process_collection_sounds(short colleciton_code, void (*process_sound)(short sound_index));
321+
322+#define mark_collection_for_loading(c) mark_collection((c), true)
323+#define mark_collection_for_unloading(c) mark_collection((c), false)
324+void mark_collection(short collection_code, bool loading);
325+void strip_collection(short collection_code);
326+void load_collections(bool with_progress_bar, bool is_opengl);
327+int count_replacement_collections();
328+void load_replacement_collections();
329+void unload_all_collections(void);
330+
331+void set_shapes_patch_data(uint8 *data, size_t length);
332+uint8* get_shapes_patch_data(size_t &length);
333+
334+// LP additions:
335+// Whether or not collection is present
336+bool is_collection_present(short collection_index);
337+// Number of texture frames in a collection (good for wall-texture error checking)
338+short get_number_of_collection_frames(short collection_index);
339+// Number of bitmaps in a collection (good for allocating texture information for OpenGL)
340+short get_number_of_collection_bitmaps(short collection_index);
341+// Which bitmap index for a frame (good for OpenGL texture rendering)
342+short get_bitmap_index(short collection_index, short low_level_shape_index);
343+// Get CLUT for collection
344+struct rgb_color_value *get_collection_colors(short collection_index, short clut_number, int &num_colors);
345+
346+// ZZZ: made these visible
347+struct low_level_shape_definition *get_low_level_shape_definition(short collection_index, short low_level_shape_index);
348+
349+
350+/* ---------- prototypes/PREPROCESS_MAP_MAC.C */
351+void setup_revert_game_info(struct game_data *game_info, struct player_start_data *start, struct entry_point *entry);
352+bool revert_game(void);
353+bool load_game(bool use_last_load);
354+bool save_game(void);
355+bool save_game_full_auto(bool inOverwriteRecent);
356+void restart_game(void);
357+
358+/* ---------- prototypes/GAME_WAD.C */
359+/* Map transferring fuctions */
360+int32 get_net_map_data_length(void *data);
361+bool process_net_map_data(void *data); /* Note that this frees it as well */
362+void *get_map_for_net_transfer(struct entry_point *entry);
363+
364+/* ---------- prototypes/VBL.C */
365+
366+void set_keyboard_controller_status(bool active);
367+bool get_keyboard_controller_status(void);
368+void pause_keyboard_controller(bool active);
369+int32 get_heartbeat_count(void);
370+void sync_heartbeat_count(void);
371+void process_action_flags(short player_identifier, const uint32 *action_flags, short count);
372+void rewind_recording(void);
373+void stop_recording(void);
374+void stop_replay(void);
375+void move_replay(void);
376+void check_recording_replaying(void);
377+short find_key_setup(short *keycodes);
378+void set_default_keys(short *keycodes, short which_default);
379+void set_keys(short *keycodes);
380+bool has_recording_file(void);
381+void increment_replay_speed(void);
382+void decrement_replay_speed(void);
383+void reset_recording_and_playback_queues(void);
384+uint32 parse_keymap(void);
385+
386+/* ---------- prototypes/GAME_DIALOGS.C */
387+
388+bool handle_preferences_dialog(void);
389+void handle_load_game(void);
390+void handle_save_game(void);
391+bool handle_start_game(void);
392+bool quit_without_saving(void);
393+
394+/* ---------- prototypes/GAME_WINDOW.C */
395+void scroll_inventory(short dy);
396+
397+/* ---------- prototypes/NETWORK.C */
398+
399+enum { // Results for network_join
400+ kNetworkJoinFailedUnjoined,
401+ kNetworkJoinFailedJoined,
402+ kNetworkJoinedNewGame,
403+ kNetworkJoinedResumeGame
404+};
405+
406+bool network_gather(bool inResumingGame);
407+int network_join(void);
408+
409+/* ---------- prototypes/NETWORK_MICROPHONE.C */
410+
411+void handle_microphone(bool triggered);
412+
413+/* ---------- prototypes/PHYSICS.C */
414+
415+void reset_absolute_positioning_device(_fixed yaw, _fixed pitch, _fixed velocity);
416+
417+/* ---------- prototypes/IMPORT_DEFINITIONS.C */
418+
419+void init_physics_wad_data();
420+void import_definition_structures(void);
421+
422+/* ---------- prototypes/KEYBOARD_DIALOG.C */
423+bool configure_key_setup(short *keycodes);
424+
425+/* --------- from PREPROCESS_MAP_MAC.C */
426+bool have_default_files(void);
427+void get_default_map_spec(FileSpecifier& File);
428+void get_default_physics_spec(FileSpecifier& File);
429+void get_default_sounds_spec(FileSpecifier& File);
430+void get_default_shapes_spec(FileSpecifier& File);
431+bool get_default_theme_spec(FileSpecifier& File);
432+// ZZZ addition: since Mac versions now search for any candidate files instead of picking
433+// by name, new interface to search for all simultaneously instead of duplicating effort.
434+void get_default_file_specs(FileSpecifier* outMapSpec, FileSpecifier* outShapesSpec, FileSpecifier* outSoundsSpec, FileSpecifier* outPhysicsSpec);
435+
436+// LP change: resets field of view to whatever the player had had when reviving
437+void ResetFieldOfView();
438+
439+// LP change: modification of Josh Elsasser's dont-switch-weapons patch
440+bool dont_switch_to_new_weapon();
441+
442+// ZZZ: corresponds with dont_switch_to_new_weapon()
443+bool dont_auto_recenter();
444+
445+// ZZZ: let code disable (standardize)/enable behavior modifiers like
446+// dont_switch and dont_auto_recenter
447+void standardize_player_behavior_modifiers();
448+void restore_custom_player_behavior_modifiers();
449+
450+// ZZZ: return whether the user's behavior matches standard behavior
451+// (either by being forced so or by chosen that way)
452+bool is_player_behavior_standard();
453+
454+// LP change: force reload of view context
455+void ReloadViewContext();
456+
457+// LP change: added infravision-parser export
458+XML_ElementParser *Infravision_GetParser();
459+
460+// LP change: added control-panel-parser export
461+XML_ElementParser *ControlPanels_GetParser();
462+
463+#endif
--- marathon/trunk/Source_Files/Misc/PlayerImage_sdl.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/PlayerImage_sdl.h (revision 526)
@@ -1,171 +1,171 @@
1-/*
2- * PlayerImage_sdl.h
3-
4- Copyright (C) 2001 and beyond by Woody Zenfell, III
5- and the "Aleph One" developers.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20- */
21-
22-#ifndef PLAYERIMAGE_SDL_H
23-#define PLAYERIMAGE_SDL_H
24-
25-#include "cseries.h"
26-
27-class PlayerImage {
28-public:
29- // Class will mark and load collection when needed; unmark when done.
30-
31- // Default constructor will randomly choose everything needed to draw a player image.
32- // You may change state values after construction, and no effort is wasted - expensive image
33- // fetching/interpretation is only performed when needed.
34- PlayerImage() :
35- mLegsView(NONE),
36- mTorsoView(NONE),
37- mLegsColor(NONE),
38- mTorsoColor(NONE),
39- mLegsAction(NONE),
40- mTorsoAction(NONE),
41- mPseudoWeapon(NONE),
42- mLegsFrame(NONE),
43- mTorsoFrame(NONE),
44- mLegsBrightness(1.0f),
45- mTorsoBrightness(1.0f),
46- mTiny(false),
47-
48- mLegsDirty(true),
49- mTorsoDirty(true),
50- mLegsValid(false),
51- mTorsoValid(false),
52-
53- mLegsSurface(NULL),
54- mTorsoSurface(NULL),
55- mLegsData(NULL),
56- mTorsoData(NULL)
57-
58- { objectCreated(); }
59-
60- ~PlayerImage();
61-
62- // In all "set" routines, a value of NONE (-1) means to pick one at random.
63- // If randomly picking values results in something that's easily detected as invalid (e.g., got a NULL pointer
64- // somewhere), values will be re-picked. If user specified any out-of-range values, or if re-picking failed
65- // too many times, you'll get an invalid torso or legs, and they won't be drawn. Use the status inquiry functions
66- // below to see whether valid values were found.
67-
68- // Views: 0 through 7. 0 is facing the viewer; each increment rotates player to HIS right 45 degrees.
69- void setLegsView(int16 inView) { if(mLegsView != inView) { mLegsView = inView; mLegsDirty = true; } }
70- void setTorsoView(int16 inView) { if(mTorsoView != inView) { mTorsoView = inView; mTorsoDirty = true; } }
71- void setView(int16 inView) { setLegsView(inView); setTorsoView(inView); }
72- void setRandomFlatteringView(); // picks torso and legs at same view; avoids "butt shots"
73-
74- // Colors: 0 through 7. The standard player/team colors.
75- void setLegsColor(int16 inColor) { if(mLegsColor != inColor) { mLegsColor = inColor; mLegsDirty = true; } }
76- void setTeamColor(int16 inColor) { setLegsColor(inColor); }
77- void setTorsoColor(int16 inColor) { if(mTorsoColor != inColor) { mTorsoColor = inColor; mTorsoDirty = true; } }
78- void setPlayerColor(int16 inColor) { setTorsoColor(inColor); }
79- void setColor(int16 inColor) { setLegsColor(inColor); setTorsoColor(inColor); }
80-
81- // Leg actions: _player_running, etc. from player.h
82- void setLegsAction(int16 inAction) { if(mLegsAction != inAction) { mLegsAction = inAction; mLegsDirty = true; } }
83- // Torso actions: _shape_weapon_firing, etc. from weapons.h
84- void setTorsoAction(int16 inAction) { if(mTorsoAction != inAction) { mTorsoAction = inAction; mTorsoDirty = true; } }
85- void setRandomAction() { setLegsAction(NONE); setTorsoAction(NONE); }
86- // Pseudo-weapon: _weapon_missile_launcher, etc. from weapons.h
87- void setPseudoWeapon(int16 inWeapon) { if(mPseudoWeapon != inWeapon) { mPseudoWeapon = inWeapon; mTorsoDirty = true; } }
88-
89- // Frame: numbered 0 through...? (depends on action, whether torso or legs, etc.)
90- void setLegsFrame(int16 inFrame) { if(mLegsFrame != inFrame) { mLegsFrame = inFrame; mLegsDirty = true; } }
91- void setTorsoFrame(int16 inFrame) { if(mTorsoFrame != inFrame) { mTorsoFrame = inFrame; mTorsoDirty = true; } }
92- void setRandomFrame() { setLegsFrame(NONE); setTorsoFrame(NONE); }
93-
94- // Brightness: 0.0f - 1.0f
95- void setLegsBrightness(float inBrightness) {
96- if(mLegsBrightness != inBrightness) { mLegsBrightness = inBrightness; mLegsDirty = true; } }
97- void setTorsoBrightness(float inBrightness) {
98- if(mTorsoBrightness != inBrightness) { mTorsoBrightness = inBrightness; mTorsoDirty = true; } }
99- void setBrightness(float inBrightness) { setLegsBrightness(inBrightness); setTorsoBrightness(inBrightness); }
100-
101- // Tiny (quarter-sized): true or false
102- void setTiny(bool inTiny) { if(mTiny != inTiny) { mTiny = inTiny; mTorsoDirty = true; mLegsDirty = true; } }
103-
104-
105- // Update routines are called to synchronize drawing data (expensive) with state
106- // Users should usually not call these - state checking and drawing routines will do it for you.
107- // Left them public just in case someone wants to force an update, e.g. to prefetch data for faster drawing later.
108- void updateLegsDrawingInfo();
109- void updateTorsoDrawingInfo();
110- void updateDrawingInfo() {
111- if(mLegsDirty) updateLegsDrawingInfo();
112- if(mTorsoDirty) updateTorsoDrawingInfo();
113- }
114-
115-
116- // Status checking routines will make sure status is up-to-date before returning value
117- bool canDrawLegs() { updateDrawingInfo(); return mLegsValid; }
118- bool canDrawTorso() { updateDrawingInfo(); return mTorsoValid; }
119- bool canDrawSomething() { updateDrawingInfo(); return mLegsValid || mTorsoValid; }
120- bool canDrawPlayer() { updateDrawingInfo(); return mLegsValid && mTorsoValid; }
121-
122- // I should really have a full complement of these, and also perhaps give the option to resolve
123- // NONEs to a value, or not.
124- int16 getTeam() { updateDrawingInfo(); return mLegsColor; }
125-
126-
127- // Drawing routines will call update routines to make sure they draw up-to-date images.
128- void drawAt(SDL_Surface* inSurface, int16 inX, int16 inY);
129-
130-
131-protected:
132- // STATE DATA
133- int16 mLegsView; // which way the legs appear to face
134- int16 mTorsoView; // which way the torso appears to face
135- int16 mLegsColor; // usually corresponds to player's team-color
136- int16 mTorsoColor; // usually corresponds to player's color
137- int16 mLegsAction; // what the legs appear to be doing
138- int16 mTorsoAction; // what the torso appears to be doing
139- int16 mPseudoWeapon; // what weapon the torso appears to be holding
140- int16 mLegsFrame; // which frame of animation the legs are at
141- int16 mTorsoFrame; // which frame of animation the torso is at
142- float mLegsBrightness; // how well-lit the legs are
143- float mTorsoBrightness; // how well-lit the torso is
144- bool mTiny; // whether the player icon is quarter-sized
145-
146- // STATE <-> DRAWING DATA LINK
147- bool mLegsDirty; // legs drawing info needs to be updated before the next draw
148- bool mTorsoDirty; // torso drawing info needs to be updated before the next draw
149-
150- bool mLegsValid; // there is valid leg-drawing data available
151- bool mTorsoValid; // there is valid torso-drawing data available
152-
153- // DRAWING DATA
154- SDL_Surface* mLegsSurface; // source image for legs
155- SDL_Surface* mTorsoSurface; // source image for torso
156- byte* mLegsData; // extra data we must hold onto and free() when done
157- byte* mTorsoData; // extra data we must hold onto and free() when done
158- SDL_Rect mDrawRect; // such that the player image has origin at 0,0
159- SDL_Rect mLegsRect; // such that the player image has origin at 0,0
160- SDL_Rect mTorsoRect; // such that the player image has origin at 0,0
161-
162-
163- // CLASS DATA
164- static int16 sNumOutstandingObjects; // count of objects created but not destroyed; used to mark/unmark collections
165-
166- // CLASS INTERNAL METHODS
167- static void objectCreated();
168- static void objectDestroyed();
169-};
170-
171-#endif//PLAYERIMAGE_SDL_H
1+/*
2+ * PlayerImage_sdl.h
3+
4+ Copyright (C) 2001 and beyond by Woody Zenfell, III
5+ and the "Aleph One" developers.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+ */
21+
22+#ifndef PLAYERIMAGE_SDL_H
23+#define PLAYERIMAGE_SDL_H
24+
25+#include "cseries.h"
26+
27+class PlayerImage {
28+public:
29+ // Class will mark and load collection when needed; unmark when done.
30+
31+ // Default constructor will randomly choose everything needed to draw a player image.
32+ // You may change state values after construction, and no effort is wasted - expensive image
33+ // fetching/interpretation is only performed when needed.
34+ PlayerImage() :
35+ mLegsView(NONE),
36+ mTorsoView(NONE),
37+ mLegsColor(NONE),
38+ mTorsoColor(NONE),
39+ mLegsAction(NONE),
40+ mTorsoAction(NONE),
41+ mPseudoWeapon(NONE),
42+ mLegsFrame(NONE),
43+ mTorsoFrame(NONE),
44+ mLegsBrightness(1.0f),
45+ mTorsoBrightness(1.0f),
46+ mTiny(false),
47+
48+ mLegsDirty(true),
49+ mTorsoDirty(true),
50+ mLegsValid(false),
51+ mTorsoValid(false),
52+
53+ mLegsSurface(NULL),
54+ mTorsoSurface(NULL),
55+ mLegsData(NULL),
56+ mTorsoData(NULL)
57+
58+ { objectCreated(); }
59+
60+ ~PlayerImage();
61+
62+ // In all "set" routines, a value of NONE (-1) means to pick one at random.
63+ // If randomly picking values results in something that's easily detected as invalid (e.g., got a NULL pointer
64+ // somewhere), values will be re-picked. If user specified any out-of-range values, or if re-picking failed
65+ // too many times, you'll get an invalid torso or legs, and they won't be drawn. Use the status inquiry functions
66+ // below to see whether valid values were found.
67+
68+ // Views: 0 through 7. 0 is facing the viewer; each increment rotates player to HIS right 45 degrees.
69+ void setLegsView(int16 inView) { if(mLegsView != inView) { mLegsView = inView; mLegsDirty = true; } }
70+ void setTorsoView(int16 inView) { if(mTorsoView != inView) { mTorsoView = inView; mTorsoDirty = true; } }
71+ void setView(int16 inView) { setLegsView(inView); setTorsoView(inView); }
72+ void setRandomFlatteringView(); // picks torso and legs at same view; avoids "butt shots"
73+
74+ // Colors: 0 through 7. The standard player/team colors.
75+ void setLegsColor(int16 inColor) { if(mLegsColor != inColor) { mLegsColor = inColor; mLegsDirty = true; } }
76+ void setTeamColor(int16 inColor) { setLegsColor(inColor); }
77+ void setTorsoColor(int16 inColor) { if(mTorsoColor != inColor) { mTorsoColor = inColor; mTorsoDirty = true; } }
78+ void setPlayerColor(int16 inColor) { setTorsoColor(inColor); }
79+ void setColor(int16 inColor) { setLegsColor(inColor); setTorsoColor(inColor); }
80+
81+ // Leg actions: _player_running, etc. from player.h
82+ void setLegsAction(int16 inAction) { if(mLegsAction != inAction) { mLegsAction = inAction; mLegsDirty = true; } }
83+ // Torso actions: _shape_weapon_firing, etc. from weapons.h
84+ void setTorsoAction(int16 inAction) { if(mTorsoAction != inAction) { mTorsoAction = inAction; mTorsoDirty = true; } }
85+ void setRandomAction() { setLegsAction(NONE); setTorsoAction(NONE); }
86+ // Pseudo-weapon: _weapon_missile_launcher, etc. from weapons.h
87+ void setPseudoWeapon(int16 inWeapon) { if(mPseudoWeapon != inWeapon) { mPseudoWeapon = inWeapon; mTorsoDirty = true; } }
88+
89+ // Frame: numbered 0 through...? (depends on action, whether torso or legs, etc.)
90+ void setLegsFrame(int16 inFrame) { if(mLegsFrame != inFrame) { mLegsFrame = inFrame; mLegsDirty = true; } }
91+ void setTorsoFrame(int16 inFrame) { if(mTorsoFrame != inFrame) { mTorsoFrame = inFrame; mTorsoDirty = true; } }
92+ void setRandomFrame() { setLegsFrame(NONE); setTorsoFrame(NONE); }
93+
94+ // Brightness: 0.0f - 1.0f
95+ void setLegsBrightness(float inBrightness) {
96+ if(mLegsBrightness != inBrightness) { mLegsBrightness = inBrightness; mLegsDirty = true; } }
97+ void setTorsoBrightness(float inBrightness) {
98+ if(mTorsoBrightness != inBrightness) { mTorsoBrightness = inBrightness; mTorsoDirty = true; } }
99+ void setBrightness(float inBrightness) { setLegsBrightness(inBrightness); setTorsoBrightness(inBrightness); }
100+
101+ // Tiny (quarter-sized): true or false
102+ void setTiny(bool inTiny) { if(mTiny != inTiny) { mTiny = inTiny; mTorsoDirty = true; mLegsDirty = true; } }
103+
104+
105+ // Update routines are called to synchronize drawing data (expensive) with state
106+ // Users should usually not call these - state checking and drawing routines will do it for you.
107+ // Left them public just in case someone wants to force an update, e.g. to prefetch data for faster drawing later.
108+ void updateLegsDrawingInfo();
109+ void updateTorsoDrawingInfo();
110+ void updateDrawingInfo() {
111+ if(mLegsDirty) updateLegsDrawingInfo();
112+ if(mTorsoDirty) updateTorsoDrawingInfo();
113+ }
114+
115+
116+ // Status checking routines will make sure status is up-to-date before returning value
117+ bool canDrawLegs() { updateDrawingInfo(); return mLegsValid; }
118+ bool canDrawTorso() { updateDrawingInfo(); return mTorsoValid; }
119+ bool canDrawSomething() { updateDrawingInfo(); return mLegsValid || mTorsoValid; }
120+ bool canDrawPlayer() { updateDrawingInfo(); return mLegsValid && mTorsoValid; }
121+
122+ // I should really have a full complement of these, and also perhaps give the option to resolve
123+ // NONEs to a value, or not.
124+ int16 getTeam() { updateDrawingInfo(); return mLegsColor; }
125+
126+
127+ // Drawing routines will call update routines to make sure they draw up-to-date images.
128+ void drawAt(SDL_Surface* inSurface, int16 inX, int16 inY);
129+
130+
131+protected:
132+ // STATE DATA
133+ int16 mLegsView; // which way the legs appear to face
134+ int16 mTorsoView; // which way the torso appears to face
135+ int16 mLegsColor; // usually corresponds to player's team-color
136+ int16 mTorsoColor; // usually corresponds to player's color
137+ int16 mLegsAction; // what the legs appear to be doing
138+ int16 mTorsoAction; // what the torso appears to be doing
139+ int16 mPseudoWeapon; // what weapon the torso appears to be holding
140+ int16 mLegsFrame; // which frame of animation the legs are at
141+ int16 mTorsoFrame; // which frame of animation the torso is at
142+ float mLegsBrightness; // how well-lit the legs are
143+ float mTorsoBrightness; // how well-lit the torso is
144+ bool mTiny; // whether the player icon is quarter-sized
145+
146+ // STATE <-> DRAWING DATA LINK
147+ bool mLegsDirty; // legs drawing info needs to be updated before the next draw
148+ bool mTorsoDirty; // torso drawing info needs to be updated before the next draw
149+
150+ bool mLegsValid; // there is valid leg-drawing data available
151+ bool mTorsoValid; // there is valid torso-drawing data available
152+
153+ // DRAWING DATA
154+ SDL_Surface* mLegsSurface; // source image for legs
155+ SDL_Surface* mTorsoSurface; // source image for torso
156+ byte* mLegsData; // extra data we must hold onto and free() when done
157+ byte* mTorsoData; // extra data we must hold onto and free() when done
158+ SDL_Rect mDrawRect; // such that the player image has origin at 0,0
159+ SDL_Rect mLegsRect; // such that the player image has origin at 0,0
160+ SDL_Rect mTorsoRect; // such that the player image has origin at 0,0
161+
162+
163+ // CLASS DATA
164+ static int16 sNumOutstandingObjects; // count of objects created but not destroyed; used to mark/unmark collections
165+
166+ // CLASS INTERNAL METHODS
167+ static void objectCreated();
168+ static void objectDestroyed();
169+};
170+
171+#endif//PLAYERIMAGE_SDL_H
--- marathon/trunk/Source_Files/Misc/Scenario.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/Scenario.h (revision 526)
@@ -1,67 +1,67 @@
1-#ifndef _SCENARIO
2-#define _SCENARIO
3-/*
4-
5- Copyright (C) 2006 and beyond by Bungie Studios, Inc.
6- and the "Aleph One" developers.
7-
8- This program is free software; you can redistribute it and/or modify
9- it under the terms of the GNU General Public License as published by
10- the Free Software Foundation; either version 3 of the License, or
11- (at your option) any later version.
12-
13- This program is distributed in the hope that it will be useful,
14- but WITHOUT ANY WARRANTY; without even the implied warranty of
15- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16- GNU General Public License for more details.
17-
18- This license is contained in the file "COPYING",
19- which is included with this source code; it is available online at
20- http://www.gnu.org/licenses/gpl.html
21-
22- Scenario tag parser
23- by Gregory Smith 2006
24-
25- This is for handling scenario compatibility info
26-*/
27-
28-
29-#include "XML_ElementParser.h"
30-#include <string>
31-#include <vector>
32-
33-using namespace std;
34-
35-class Scenario
36-{
37-public:
38- static Scenario *instance();
39-
40- const string GetName() { return m_name; }
41- void SetName(const string name) { m_name = string(name, 0, 31); }
42-
43- const string GetVersion() { return m_version; }
44- void SetVersion(const string version) { m_version = string(version, 0, 7); }
45-
46- const string GetID() { return m_id; }
47- void SetID(const string id) { m_id = string(id, 0, 23); }
48-
49- bool IsCompatible(const string);
50- void AddCompatible(const string);
51-
52-private:
53- Scenario() { }
54-
55- string m_name;
56- string m_version;
57- string m_id;
58-
59- vector<string> m_compatibleVersions;
60-
61- static Scenario *m_instance;
62-};
63-
64-// Scenario parser: name is "scenario"
65-XML_ElementParser *Scenario_GetParser();
66-
67-#endif
1+#ifndef _SCENARIO
2+#define _SCENARIO
3+/*
4+
5+ Copyright (C) 2006 and beyond by Bungie Studios, Inc.
6+ and the "Aleph One" developers.
7+
8+ This program is free software; you can redistribute it and/or modify
9+ it under the terms of the GNU General Public License as published by
10+ the Free Software Foundation; either version 3 of the License, or
11+ (at your option) any later version.
12+
13+ This program is distributed in the hope that it will be useful,
14+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ GNU General Public License for more details.
17+
18+ This license is contained in the file "COPYING",
19+ which is included with this source code; it is available online at
20+ http://www.gnu.org/licenses/gpl.html
21+
22+ Scenario tag parser
23+ by Gregory Smith 2006
24+
25+ This is for handling scenario compatibility info
26+*/
27+
28+
29+#include "XML_ElementParser.h"
30+#include <string>
31+#include <vector>
32+
33+using namespace std;
34+
35+class Scenario
36+{
37+public:
38+ static Scenario *instance();
39+
40+ const string GetName() { return m_name; }
41+ void SetName(const string name) { m_name = string(name, 0, 31); }
42+
43+ const string GetVersion() { return m_version; }
44+ void SetVersion(const string version) { m_version = string(version, 0, 7); }
45+
46+ const string GetID() { return m_id; }
47+ void SetID(const string id) { m_id = string(id, 0, 23); }
48+
49+ bool IsCompatible(const string);
50+ void AddCompatible(const string);
51+
52+private:
53+ Scenario() { }
54+
55+ string m_name;
56+ string m_version;
57+ string m_id;
58+
59+ vector<string> m_compatibleVersions;
60+
61+ static Scenario *m_instance;
62+};
63+
64+// Scenario parser: name is "scenario"
65+XML_ElementParser *Scenario_GetParser();
66+
67+#endif
--- marathon/trunk/Source_Files/Misc/CircularQueue.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/CircularQueue.h (revision 526)
@@ -1,125 +1,125 @@
1-/*
2- * CircularQueue.h
3- * created for Marathon: Aleph One <http://source.bungie.org/>
4-
5- Copyright (C) 2002 and beyond by Woody Zenfell, III
6- and the "Aleph One" developers.
7-
8- This program is free software; you can redistribute it and/or modify
9- it under the terms of the GNU General Public License as published by
10- the Free Software Foundation; either version 3 of the License, or
11- (at your option) any later version.
12-
13- This program is distributed in the hope that it will be useful,
14- but WITHOUT ANY WARRANTY; without even the implied warranty of
15- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16- GNU General Public License for more details.
17-
18- This license is contained in the file "COPYING",
19- which is included with this source code; it is available online at
20- http://www.gnu.org/licenses/gpl.html
21-
22- * The code in this file is licensed to you under the GNU GPL. As the copyright holder,
23- * however, I reserve the right to use this code as I see fit, without being bound by the
24- * GPL's terms. This exemption is not intended to apply to modified versions of this file -
25- * if I were to use a modified version, I would be a licensee of whomever modified it, and
26- * thus must observe the GPL terms.
27- *
28- * Done a thousand times a thousand ways, this is another circular queue.
29- * Hope it's useful. (And correct.)
30- *
31- * Created by woody in February 2002.
32- *
33- * May 8, 2003 (Woody Zenfell): minor modifications; can now copy/assign queues.
34- */
35-
36-#ifndef CIRCULAR_QUEUE_H
37-#define CIRCULAR_QUEUE_H
38-
39-template<typename T>
40-class CircularQueue {
41-public:
42- CircularQueue() : mData(NULL) { reset(0); }
43-
44- explicit CircularQueue(unsigned int inSize) : mData(NULL) { reset(inSize); }
45-
46- // The queue being copied had best not change while we're copying...
47- CircularQueue(const CircularQueue<T>& o) : mData(NULL) {
48- *this = o;
49- }
50-
51- CircularQueue<T>& operator =(const CircularQueue<T>& o) {
52- if(&o != this)
53- {
54- reset(o.getTotalSpace());
55- for(unsigned int i = 0; i < o.getCountOfElements(); i++)
56- enqueue(o.mData[o.getReadIndex(i)]);
57- }
58- return *this;
59- }
60-
61- void reset() { reset(getTotalSpace()); }
62-
63- void reset(unsigned int inSize) {
64- // We need size+1 elements of storage to allow size elements in queue
65- unsigned int theStorageCount = inSize + 1;
66-
67- // Guard against wrap-around
68- assert(theStorageCount > inSize);
69-
70- mReadIndex = mWriteIndex = 0;
71-
72- if(theStorageCount != mQueueSize || mData == NULL) {
73- mQueueSize = theStorageCount;
74- if(mData != NULL)
75- delete [] mData;
76- mData = new T[mQueueSize];
77- }
78- }
79-
80- unsigned int getCountOfElements() const
81- { return (mQueueSize > 0) ? (mQueueSize + mWriteIndex - mReadIndex) % mQueueSize : 0; }
82-
83- unsigned int getRemainingSpace() const
84- { return getTotalSpace() - getCountOfElements(); }
85-
86- unsigned int getTotalSpace() const { return (mQueueSize > 0) ? mQueueSize - 1 : 0; }
87-
88- const T& peek() const { return mData[getReadIndex()]; }
89-
90- void dequeue(unsigned int inAmount = 1) { advanceReadIndex(inAmount); }
91-
92- void enqueue(const T& inData) { mData[getWriteIndex()] = inData; advanceWriteIndex(); }
93-
94- virtual ~CircularQueue() { if(mData != NULL) delete [] mData; }
95-
96-protected:
97- unsigned int getReadIndex(unsigned int inOffset = 0) const
98- { assert(getCountOfElements() > inOffset); return (mReadIndex + inOffset) % mQueueSize; }
99- unsigned int getWriteIndex(unsigned int inOffset = 0) const
100- { assert(getRemainingSpace() > inOffset); return (mWriteIndex + inOffset) % mQueueSize; }
101-
102- unsigned int advanceReadIndex(unsigned int inAmount = 1) {
103- if(inAmount > 0) {
104- assert(inAmount <= getCountOfElements());
105- mReadIndex = (mReadIndex + inAmount) % mQueueSize;
106- }
107- return mReadIndex;
108- }
109-
110- unsigned int advanceWriteIndex(unsigned int inAmount = 1) {
111- if(inAmount > 0) {
112- assert(inAmount <= getRemainingSpace());
113- mWriteIndex = (mWriteIndex + inAmount) % mQueueSize;
114- }
115- return mWriteIndex;
116- }
117-
118- unsigned int mReadIndex;
119- unsigned int mWriteIndex;
120- unsigned int mQueueSize;
121-
122- T* mData;
123-};
124-
125-#endif // CIRCULAR_QUEUE_H
1+/*
2+ * CircularQueue.h
3+ * created for Marathon: Aleph One <http://source.bungie.org/>
4+
5+ Copyright (C) 2002 and beyond by Woody Zenfell, III
6+ and the "Aleph One" developers.
7+
8+ This program is free software; you can redistribute it and/or modify
9+ it under the terms of the GNU General Public License as published by
10+ the Free Software Foundation; either version 3 of the License, or
11+ (at your option) any later version.
12+
13+ This program is distributed in the hope that it will be useful,
14+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ GNU General Public License for more details.
17+
18+ This license is contained in the file "COPYING",
19+ which is included with this source code; it is available online at
20+ http://www.gnu.org/licenses/gpl.html
21+
22+ * The code in this file is licensed to you under the GNU GPL. As the copyright holder,
23+ * however, I reserve the right to use this code as I see fit, without being bound by the
24+ * GPL's terms. This exemption is not intended to apply to modified versions of this file -
25+ * if I were to use a modified version, I would be a licensee of whomever modified it, and
26+ * thus must observe the GPL terms.
27+ *
28+ * Done a thousand times a thousand ways, this is another circular queue.
29+ * Hope it's useful. (And correct.)
30+ *
31+ * Created by woody in February 2002.
32+ *
33+ * May 8, 2003 (Woody Zenfell): minor modifications; can now copy/assign queues.
34+ */
35+
36+#ifndef CIRCULAR_QUEUE_H
37+#define CIRCULAR_QUEUE_H
38+
39+template<typename T>
40+class CircularQueue {
41+public:
42+ CircularQueue() : mData(NULL) { reset(0); }
43+
44+ explicit CircularQueue(unsigned int inSize) : mData(NULL) { reset(inSize); }
45+
46+ // The queue being copied had best not change while we're copying...
47+ CircularQueue(const CircularQueue<T>& o) : mData(NULL) {
48+ *this = o;
49+ }
50+
51+ CircularQueue<T>& operator =(const CircularQueue<T>& o) {
52+ if(&o != this)
53+ {
54+ reset(o.getTotalSpace());
55+ for(unsigned int i = 0; i < o.getCountOfElements(); i++)
56+ enqueue(o.mData[o.getReadIndex(i)]);
57+ }
58+ return *this;
59+ }
60+
61+ void reset() { reset(getTotalSpace()); }
62+
63+ void reset(unsigned int inSize) {
64+ // We need size+1 elements of storage to allow size elements in queue
65+ unsigned int theStorageCount = inSize + 1;
66+
67+ // Guard against wrap-around
68+ assert(theStorageCount > inSize);
69+
70+ mReadIndex = mWriteIndex = 0;
71+
72+ if(theStorageCount != mQueueSize || mData == NULL) {
73+ mQueueSize = theStorageCount;
74+ if(mData != NULL)
75+ delete [] mData;
76+ mData = new T[mQueueSize];
77+ }
78+ }
79+
80+ unsigned int getCountOfElements() const
81+ { return (mQueueSize > 0) ? (mQueueSize + mWriteIndex - mReadIndex) % mQueueSize : 0; }
82+
83+ unsigned int getRemainingSpace() const
84+ { return getTotalSpace() - getCountOfElements(); }
85+
86+ unsigned int getTotalSpace() const { return (mQueueSize > 0) ? mQueueSize - 1 : 0; }
87+
88+ const T& peek() const { return mData[getReadIndex()]; }
89+
90+ void dequeue(unsigned int inAmount = 1) { advanceReadIndex(inAmount); }
91+
92+ void enqueue(const T& inData) { mData[getWriteIndex()] = inData; advanceWriteIndex(); }
93+
94+ virtual ~CircularQueue() { if(mData != NULL) delete [] mData; }
95+
96+protected:
97+ unsigned int getReadIndex(unsigned int inOffset = 0) const
98+ { assert(getCountOfElements() > inOffset); return (mReadIndex + inOffset) % mQueueSize; }
99+ unsigned int getWriteIndex(unsigned int inOffset = 0) const
100+ { assert(getRemainingSpace() > inOffset); return (mWriteIndex + inOffset) % mQueueSize; }
101+
102+ unsigned int advanceReadIndex(unsigned int inAmount = 1) {
103+ if(inAmount > 0) {
104+ assert(inAmount <= getCountOfElements());
105+ mReadIndex = (mReadIndex + inAmount) % mQueueSize;
106+ }
107+ return mReadIndex;
108+ }
109+
110+ unsigned int advanceWriteIndex(unsigned int inAmount = 1) {
111+ if(inAmount > 0) {
112+ assert(inAmount <= getRemainingSpace());
113+ mWriteIndex = (mWriteIndex + inAmount) % mQueueSize;
114+ }
115+ return mWriteIndex;
116+ }
117+
118+ unsigned int mReadIndex;
119+ unsigned int mWriteIndex;
120+ unsigned int mQueueSize;
121+
122+ T* mData;
123+};
124+
125+#endif // CIRCULAR_QUEUE_H
--- marathon/trunk/Source_Files/Misc/CircularByteBuffer.cpp (revision 525)
+++ marathon/trunk/Source_Files/Misc/CircularByteBuffer.cpp (revision 526)
@@ -1,166 +1,166 @@
1-/*
2- * CircularByteBuffer.cpp
3- * created for Marathon: Aleph One <http://source.bungie.org/>
4-
5- Copyright (C) 2003 Woody Zenfell, III
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20-
21- * A circular queue of bytes, with support for mass enqueueing from/peeking to caller's buffer
22- *
23- * Created by Woody Zenfell, III on Sun Jun 29 2003.
24-
25- July 19, 2003 (Woody Zenfell):
26- Additional "NoCopy" interface may let clients avoid a copy, though it's not as safe.
27-
28- */
29-
30-#include "cseries.h" // assert()
31-
32-#include "CircularByteBuffer.h"
33-
34-#include <algorithm> // std::min()
35-
36-// static
37-std::pair<unsigned int, unsigned int>
38-CircularByteBuffer::splitIntoChunks(unsigned int inByteCount, unsigned int inStartingIndex, unsigned int inQueueSize)
39-{
40- // Copy, potentially, two separate chunks (one at end of buffer; one at beginning)
41- unsigned int theSpaceAtEndOfBuffer = inQueueSize - inStartingIndex;
42- unsigned int theFirstChunkSize = std::min(inByteCount, theSpaceAtEndOfBuffer);
43- unsigned int theSecondChunkSize = inByteCount - theFirstChunkSize;
44-
45- return std::pair<unsigned int, unsigned int>(theFirstChunkSize, theSecondChunkSize);
46-}
47-
48-
49-void
50-CircularByteBuffer::enqueueBytes(const void* inBytes, unsigned int inByteCount)
51-{
52- // I believe everything works right without this check, but it makes me feel safer anyway.
53- if(inByteCount > 0)
54- {
55- assert(inByteCount <= getRemainingSpace());
56-
57- const char* theBytes = static_cast<const char*>(inBytes);
58-
59- std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mWriteIndex, mQueueSize);
60-
61- memcpy(&(mData[mWriteIndex]), theBytes, theChunkSizes.first);
62-
63- if(theChunkSizes.second > 0)
64- memcpy(mData, &(theBytes[theChunkSizes.first]), theChunkSizes.second);
65-
66- advanceWriteIndex(inByteCount);
67- }
68-}
69-
70-
71-void
72-CircularByteBuffer::enqueueBytesNoCopyStart(unsigned int inByteCount, void** outFirstBytes, unsigned int* outFirstByteCount,
73- void** outSecondBytes, unsigned int* outSecondByteCount)
74-{
75- void* theFirstBytes = NULL;
76- void* theSecondBytes = NULL;
77- unsigned int theFirstByteCount = 0;
78- unsigned int theSecondByteCount = 0;
79-
80- if(inByteCount > 0)
81- {
82- assert(inByteCount <= getRemainingSpace());
83-
84- std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mWriteIndex, mQueueSize);
85-
86- theFirstBytes = &(mData[getWriteIndex()]);
87- theFirstByteCount = theChunkSizes.first;
88- theSecondByteCount = theChunkSizes.second;
89- theSecondBytes = (theSecondByteCount > 0) ? mData : NULL;
90- }
91-
92- if(outFirstBytes != NULL)
93- *outFirstBytes = theFirstBytes;
94-
95- if(outFirstByteCount != NULL)
96- *outFirstByteCount = theFirstByteCount;
97-
98- if(outSecondBytes != NULL)
99- *outSecondBytes = theSecondBytes;
100-
101- if(outSecondByteCount != NULL)
102- *outSecondByteCount = theSecondByteCount;
103-}
104-
105-
106-void
107-CircularByteBuffer::enqueueBytesNoCopyFinish(unsigned int inActualByteCount)
108-{
109- if(inActualByteCount > 0)
110- advanceWriteIndex(inActualByteCount);
111-}
112-
113-
114-void
115-CircularByteBuffer::peekBytes(void* outBytes, unsigned int inByteCount)
116-{
117- // I believe everything works right without this check, but it makes me feel safer anyway.
118- if(inByteCount > 0)
119- {
120- assert(inByteCount <= getCountOfElements());
121-
122- char* theBytes = static_cast<char*>(outBytes);
123-
124- std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mReadIndex, mQueueSize);
125-
126- memcpy(theBytes, &(mData[mReadIndex]), theChunkSizes.first);
127-
128- if(theChunkSizes.second > 0)
129- memcpy(&(theBytes[theChunkSizes.first]), mData, theChunkSizes.second);
130- }
131-}
132-
133-
134-void
135-CircularByteBuffer::peekBytesNoCopy(unsigned int inByteCount, const void** outFirstBytes, unsigned int* outFirstByteCount,
136- const void** outSecondBytes, unsigned int* outSecondByteCount)
137-{
138- void* theFirstBytes = NULL;
139- void* theSecondBytes = NULL;
140- unsigned int theFirstByteCount = 0;
141- unsigned int theSecondByteCount = 0;
142-
143- if(inByteCount > 0)
144- {
145- assert(inByteCount <= getCountOfElements());
146-
147- std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mReadIndex, mQueueSize);
148-
149- theFirstBytes = &(mData[getReadIndex()]);
150- theFirstByteCount = theChunkSizes.first;
151- theSecondByteCount = theChunkSizes.second;
152- theSecondBytes = (theSecondByteCount > 0) ? mData : NULL;
153- }
154-
155- if(outFirstBytes != NULL)
156- *outFirstBytes = theFirstBytes;
157-
158- if(outFirstByteCount != NULL)
159- *outFirstByteCount = theFirstByteCount;
160-
161- if(outSecondBytes != NULL)
162- *outSecondBytes = theSecondBytes;
163-
164- if(outSecondByteCount != NULL)
165- *outSecondByteCount = theSecondByteCount;
166-}
1+/*
2+ * CircularByteBuffer.cpp
3+ * created for Marathon: Aleph One <http://source.bungie.org/>
4+
5+ Copyright (C) 2003 Woody Zenfell, III
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+
21+ * A circular queue of bytes, with support for mass enqueueing from/peeking to caller's buffer
22+ *
23+ * Created by Woody Zenfell, III on Sun Jun 29 2003.
24+
25+ July 19, 2003 (Woody Zenfell):
26+ Additional "NoCopy" interface may let clients avoid a copy, though it's not as safe.
27+
28+ */
29+
30+#include "cseries.h" // assert()
31+
32+#include "CircularByteBuffer.h"
33+
34+#include <algorithm> // std::min()
35+
36+// static
37+std::pair<unsigned int, unsigned int>
38+CircularByteBuffer::splitIntoChunks(unsigned int inByteCount, unsigned int inStartingIndex, unsigned int inQueueSize)
39+{
40+ // Copy, potentially, two separate chunks (one at end of buffer; one at beginning)
41+ unsigned int theSpaceAtEndOfBuffer = inQueueSize - inStartingIndex;
42+ unsigned int theFirstChunkSize = std::min(inByteCount, theSpaceAtEndOfBuffer);
43+ unsigned int theSecondChunkSize = inByteCount - theFirstChunkSize;
44+
45+ return std::pair<unsigned int, unsigned int>(theFirstChunkSize, theSecondChunkSize);
46+}
47+
48+
49+void
50+CircularByteBuffer::enqueueBytes(const void* inBytes, unsigned int inByteCount)
51+{
52+ // I believe everything works right without this check, but it makes me feel safer anyway.
53+ if(inByteCount > 0)
54+ {
55+ assert(inByteCount <= getRemainingSpace());
56+
57+ const char* theBytes = static_cast<const char*>(inBytes);
58+
59+ std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mWriteIndex, mQueueSize);
60+
61+ memcpy(&(mData[mWriteIndex]), theBytes, theChunkSizes.first);
62+
63+ if(theChunkSizes.second > 0)
64+ memcpy(mData, &(theBytes[theChunkSizes.first]), theChunkSizes.second);
65+
66+ advanceWriteIndex(inByteCount);
67+ }
68+}
69+
70+
71+void
72+CircularByteBuffer::enqueueBytesNoCopyStart(unsigned int inByteCount, void** outFirstBytes, unsigned int* outFirstByteCount,
73+ void** outSecondBytes, unsigned int* outSecondByteCount)
74+{
75+ void* theFirstBytes = NULL;
76+ void* theSecondBytes = NULL;
77+ unsigned int theFirstByteCount = 0;
78+ unsigned int theSecondByteCount = 0;
79+
80+ if(inByteCount > 0)
81+ {
82+ assert(inByteCount <= getRemainingSpace());
83+
84+ std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mWriteIndex, mQueueSize);
85+
86+ theFirstBytes = &(mData[getWriteIndex()]);
87+ theFirstByteCount = theChunkSizes.first;
88+ theSecondByteCount = theChunkSizes.second;
89+ theSecondBytes = (theSecondByteCount > 0) ? mData : NULL;
90+ }
91+
92+ if(outFirstBytes != NULL)
93+ *outFirstBytes = theFirstBytes;
94+
95+ if(outFirstByteCount != NULL)
96+ *outFirstByteCount = theFirstByteCount;
97+
98+ if(outSecondBytes != NULL)
99+ *outSecondBytes = theSecondBytes;
100+
101+ if(outSecondByteCount != NULL)
102+ *outSecondByteCount = theSecondByteCount;
103+}
104+
105+
106+void
107+CircularByteBuffer::enqueueBytesNoCopyFinish(unsigned int inActualByteCount)
108+{
109+ if(inActualByteCount > 0)
110+ advanceWriteIndex(inActualByteCount);
111+}
112+
113+
114+void
115+CircularByteBuffer::peekBytes(void* outBytes, unsigned int inByteCount)
116+{
117+ // I believe everything works right without this check, but it makes me feel safer anyway.
118+ if(inByteCount > 0)
119+ {
120+ assert(inByteCount <= getCountOfElements());
121+
122+ char* theBytes = static_cast<char*>(outBytes);
123+
124+ std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mReadIndex, mQueueSize);
125+
126+ memcpy(theBytes, &(mData[mReadIndex]), theChunkSizes.first);
127+
128+ if(theChunkSizes.second > 0)
129+ memcpy(&(theBytes[theChunkSizes.first]), mData, theChunkSizes.second);
130+ }
131+}
132+
133+
134+void
135+CircularByteBuffer::peekBytesNoCopy(unsigned int inByteCount, const void** outFirstBytes, unsigned int* outFirstByteCount,
136+ const void** outSecondBytes, unsigned int* outSecondByteCount)
137+{
138+ void* theFirstBytes = NULL;
139+ void* theSecondBytes = NULL;
140+ unsigned int theFirstByteCount = 0;
141+ unsigned int theSecondByteCount = 0;
142+
143+ if(inByteCount > 0)
144+ {
145+ assert(inByteCount <= getCountOfElements());
146+
147+ std::pair<unsigned int, unsigned int> theChunkSizes = splitIntoChunks(inByteCount, mReadIndex, mQueueSize);
148+
149+ theFirstBytes = &(mData[getReadIndex()]);
150+ theFirstByteCount = theChunkSizes.first;
151+ theSecondByteCount = theChunkSizes.second;
152+ theSecondBytes = (theSecondByteCount > 0) ? mData : NULL;
153+ }
154+
155+ if(outFirstBytes != NULL)
156+ *outFirstBytes = theFirstBytes;
157+
158+ if(outFirstByteCount != NULL)
159+ *outFirstByteCount = theFirstByteCount;
160+
161+ if(outSecondBytes != NULL)
162+ *outSecondBytes = theSecondBytes;
163+
164+ if(outSecondByteCount != NULL)
165+ *outSecondByteCount = theSecondByteCount;
166+}
--- marathon/trunk/Source_Files/Misc/preference_dialogs.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/preference_dialogs.h (revision 526)
@@ -1,79 +1,79 @@
1-/*
2-
3- Copyright (C) 2006 and beyond by Bungie Studios, Inc.
4- and the "Aleph One" developers.
5-
6- This program is free software; you can redistribute it and/or modify
7- it under the terms of the GNU General Public License as published by
8- the Free Software Foundation; either version 3 of the License, or
9- (at your option) any later version.
10-
11- This program is distributed in the hope that it will be useful,
12- but WITHOUT ANY WARRANTY; without even the implied warranty of
13- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- GNU General Public License for more details.
15-
16- This license is contained in the file "COPYING",
17- which is included with this source code; it is available online at
18- http://www.gnu.org/licenses/gpl.html
19-
20-*/
21-
22-#ifndef PREFERENCE_DIALOGS_H
23-#define PREFERENCE_DIALOGS_H
24-
25-#include "shared_widgets.h"
26-#include "OGL_Setup.h"
27-
28-class OpenGLDialog
29-{
30-public:
31- // Abstract factory; concrete type determined at link-time
32- static std::auto_ptr<OpenGLDialog> Create(int theSelectedRenderer);
33-
34- void OpenGLPrefsByRunning ();
35-
36- virtual ~OpenGLDialog ();
37-protected:
38- OpenGLDialog ();
39-
40- virtual bool Run () = 0;
41- virtual void Stop (bool result) = 0;
42-
43- ButtonWidget* m_cancelWidget;
44- ButtonWidget* m_okWidget;
45-
46- ToggleWidget* m_zBufferWidget;
47- ToggleWidget* m_fogWidget;
48- ToggleWidget* m_staticEffectWidget;
49- ToggleWidget* m_colourEffectsWidget;
50- ToggleWidget* m_transparentLiquidsWidget;
51- ToggleWidget* m_3DmodelsWidget;
52- ToggleWidget* m_blurWidget;
53- ToggleWidget* m_bumpWidget;
54-
55- ToggleWidget* m_colourTheVoidWidget;
56- ColourPickerWidget* m_voidColourWidget;
57-
58- SelectorWidget* m_fsaaWidget;
59-
60- SelectorWidget* m_anisotropicWidget;
61-
62- ToggleWidget* m_sRGBWidget;
63-
64- SelectorWidget* m_textureQualityWidget [OGL_NUMBER_OF_TEXTURE_TYPES];
65- SelectorWidget* m_modelQualityWidget;
66-
67- ToggleWidget* m_geForceFixWidget;
68- ToggleWidget* m_useNPOTWidget;
69- ToggleWidget* m_vsyncWidget;
70- SelectSelectorWidget* m_wallsFilterWidget;
71- SelectSelectorWidget* m_spritesFilterWidget;
72-
73- SelectSelectorWidget* m_nearFiltersWidget[OGL_NUMBER_OF_TEXTURE_TYPES];
74-
75- SelectorWidget* m_textureResolutionWidget [OGL_NUMBER_OF_TEXTURE_TYPES];
76- SelectorWidget* m_textureDepthWidget [OGL_NUMBER_OF_TEXTURE_TYPES];
77-};
78-
79-#endif
1+/*
2+
3+ Copyright (C) 2006 and beyond by Bungie Studios, Inc.
4+ and the "Aleph One" developers.
5+
6+ This program is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
10+
11+ This program is distributed in the hope that it will be useful,
12+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ GNU General Public License for more details.
15+
16+ This license is contained in the file "COPYING",
17+ which is included with this source code; it is available online at
18+ http://www.gnu.org/licenses/gpl.html
19+
20+*/
21+
22+#ifndef PREFERENCE_DIALOGS_H
23+#define PREFERENCE_DIALOGS_H
24+
25+#include "shared_widgets.h"
26+#include "OGL_Setup.h"
27+
28+class OpenGLDialog
29+{
30+public:
31+ // Abstract factory; concrete type determined at link-time
32+ static std::auto_ptr<OpenGLDialog> Create(int theSelectedRenderer);
33+
34+ void OpenGLPrefsByRunning ();
35+
36+ virtual ~OpenGLDialog ();
37+protected:
38+ OpenGLDialog ();
39+
40+ virtual bool Run () = 0;
41+ virtual void Stop (bool result) = 0;
42+
43+ ButtonWidget* m_cancelWidget;
44+ ButtonWidget* m_okWidget;
45+
46+ ToggleWidget* m_zBufferWidget;
47+ ToggleWidget* m_fogWidget;
48+ ToggleWidget* m_staticEffectWidget;
49+ ToggleWidget* m_colourEffectsWidget;
50+ ToggleWidget* m_transparentLiquidsWidget;
51+ ToggleWidget* m_3DmodelsWidget;
52+ ToggleWidget* m_blurWidget;
53+ ToggleWidget* m_bumpWidget;
54+
55+ ToggleWidget* m_colourTheVoidWidget;
56+ ColourPickerWidget* m_voidColourWidget;
57+
58+ SelectorWidget* m_fsaaWidget;
59+
60+ SelectorWidget* m_anisotropicWidget;
61+
62+ ToggleWidget* m_sRGBWidget;
63+
64+ SelectorWidget* m_textureQualityWidget [OGL_NUMBER_OF_TEXTURE_TYPES];
65+ SelectorWidget* m_modelQualityWidget;
66+
67+ ToggleWidget* m_geForceFixWidget;
68+ ToggleWidget* m_useNPOTWidget;
69+ ToggleWidget* m_vsyncWidget;
70+ SelectSelectorWidget* m_wallsFilterWidget;
71+ SelectSelectorWidget* m_spritesFilterWidget;
72+
73+ SelectSelectorWidget* m_nearFiltersWidget[OGL_NUMBER_OF_TEXTURE_TYPES];
74+
75+ SelectorWidget* m_textureResolutionWidget [OGL_NUMBER_OF_TEXTURE_TYPES];
76+ SelectorWidget* m_textureDepthWidget [OGL_NUMBER_OF_TEXTURE_TYPES];
77+};
78+
79+#endif
--- marathon/trunk/Source_Files/Misc/key_definitions.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/key_definitions.h (revision 526)
@@ -1,347 +1,347 @@
1-#ifndef __KEY_DEFINITIONS_H
2-#define __KEY_DEFINITIONS_H
3-
4-/*
5-
6- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
7- and the "Aleph One" developers.
8-
9- This program is free software; you can redistribute it and/or modify
10- it under the terms of the GNU General Public License as published by
11- the Free Software Foundation; either version 3 of the License, or
12- (at your option) any later version.
13-
14- This program is distributed in the hope that it will be useful,
15- but WITHOUT ANY WARRANTY; without even the implied warranty of
16- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17- GNU General Public License for more details.
18-
19- This license is contained in the file "COPYING",
20- which is included with this source code; it is available online at
21- http://www.gnu.org/licenses/gpl.html
22-
23-*/
24-
25-/*
26- * Monday, September 12, 1994 12:45:17 PM (alain)
27- * This header file can only be included by one other file. right now that's vbl.c
28- *
29- */
30-
31-
32-/* Constants */
33-enum /* special flag types */
34-{
35- _double_flag,
36- _latched_flag
37-};
38-
39-/* Structures */
40-struct blacklist_data
41-{
42- int16 offset1, offset2; /* the combination of keys that should be blacklisted */
43- int16 mask1, mask2; /* help for finding them in the keymap */
44-};
45-
46-struct special_flag_data
47-{
48- int16 type;
49- int32 flag, alternate_flag;
50- int16 persistence;
51-};
52-
53-struct key_definition
54-{
55-#ifdef SDL
56- SDLKey offset;
57- uint32 action_flag;
58-#else
59- int16 offset;
60- int32 action_flag;
61- int16 mask;
62-#endif
63-};
64-
65-/*
66- * various key setups that the user can get.
67- * NOTE that these arrays must all be in the same order, and they must
68- * be in the same order as the text edit boxes in the "setup keys" dialog
69- *
70- */
71-
72-#define NUMBER_OF_STANDARD_KEY_DEFINITIONS (sizeof(standard_key_definitions)/sizeof(struct key_definition))
73-static struct key_definition standard_key_definitions[]=
74-{
75-#ifdef SDL
76- /* keypad */
77- {SDLK_KP8, _moving_forward},
78- {SDLK_KP5, _moving_backward},
79- {SDLK_KP4, _turning_left},
80- {SDLK_KP6, _turning_right},
81-
82- /* zx translation */
83- {SDLK_z, _sidestepping_left},
84- {SDLK_x, _sidestepping_right},
85-
86- /* as looking */
87- {SDLK_a, _looking_left},
88- {SDLK_s, _looking_right},
89-
90- /* dcv vertical looking */
91- {SDLK_d, _looking_up},
92- {SDLK_c, _looking_down},
93- {SDLK_v, _looking_center},
94-
95- /* KP7/KP9 for weapon cycling */
96- {SDLK_KP7, _cycle_weapons_backward},
97- {SDLK_KP9, _cycle_weapons_forward},
98-
99- /* space for primary trigger, option for alternate trigger */
100- {SDLK_SPACE, _left_trigger_state},
101- {SDLK_LALT, _right_trigger_state},
102-
103- /* shift, control and command modifiers */
104- {SDLK_LSHIFT, _sidestep_dont_turn},
105- {SDLK_LCTRL, _run_dont_walk},
106- {SDLK_LMETA, _look_dont_turn},
107-
108- /* tab for action */
109- {SDLK_TAB, _action_trigger_state},
110-
111- /* m for toggle between normal and overhead map view */
112- {SDLK_m, _toggle_map},
113-
114- /* ` for using the microphone */
115- {SDLK_BACKQUOTE, _microphone_button}
116-#else
117- /* keypad */
118- {0x5b, _moving_forward},
119- {0x57, _moving_backward},
120- {0x56, _turning_left},
121- {0x58, _turning_right},
122-
123- /* zx translation */
124- {0x06, _sidestepping_left},
125- {0x07, _sidestepping_right},
126-
127- /* as looking */
128- {0x00, _looking_left},
129- {0x01, _looking_right},
130-
131- /* dcv vertical looking */
132- {0x02, _looking_up},
133- {0x08, _looking_down},
134- {0x09, _looking_center},
135-
136- /* KP7/KP9 for weapon cycling */
137- {0x59, _cycle_weapons_backward},
138- {0x5c, _cycle_weapons_forward},
139-
140- /* space for primary trigger, option for alternate trigger */
141- {0x31, _left_trigger_state},
142- {0x3a, _right_trigger_state},
143-
144- /* shift, control and command modifiers */
145- {0x37, _sidestep_dont_turn},
146- {0x3b, _run_dont_walk},
147- {0x38, _look_dont_turn},
148-
149- /* tab for action */
150- {0x30, _action_trigger_state},
151-
152- /* m for toggle between normal and overhead map view */
153- {0x2e, _toggle_map},
154-
155- /* ` for using the microphone */
156- {0x32, _microphone_button}
157-#endif
158-};
159-
160-#define NUMBER_OF_LEFT_HANDED_KEY_DEFINITIONS (sizeof(left_handed_key_definitions)/sizeof(struct key_definition))
161-static struct key_definition left_handed_key_definitions[]=
162-{
163-#ifdef SDL
164- /* arrows */
165- {SDLK_UP, _moving_forward},
166- {SDLK_DOWN, _moving_backward},
167- {SDLK_LEFT, _turning_left},
168- {SDLK_RIGHT, _turning_right},
169-
170- /* zx translation */
171- {SDLK_z, _sidestepping_left},
172- {SDLK_x, _sidestepping_right},
173-
174- /* as looking */
175- {SDLK_a, _looking_left},
176- {SDLK_s, _looking_right},
177-
178- /* dcv vertical looking */
179- {SDLK_d, _looking_up},
180- {SDLK_c, _looking_down},
181- {SDLK_v, _looking_center},
182-
183- /* ;' for weapon cycling */
184- {SDLK_SEMICOLON, _cycle_weapons_backward},
185- {SDLK_QUOTE, _cycle_weapons_forward},
186-
187- /* space for primary trigger, option for alternate trigger */
188- {SDLK_SPACE, _left_trigger_state},
189- {SDLK_LALT, _right_trigger_state},
190-
191- /* shift, control and command modifiers */
192- {SDLK_LSHIFT, _sidestep_dont_turn},
193- {SDLK_LCTRL, _run_dont_walk},
194- {SDLK_LMETA, _look_dont_turn},
195-
196- /* tab for action */
197- {SDLK_TAB, _action_trigger_state},
198-
199- /* m for toggle between normal and overhead map view */
200- {SDLK_m, _toggle_map},
201-
202- /* ` for using the microphone */
203- {SDLK_BACKQUOTE, _microphone_button}
204-#else
205- /* arrows */
206- {0x7e, _moving_forward},
207- {0x7d, _moving_backward},
208- {0x7b, _turning_left},
209- {0x7c, _turning_right},
210-
211- /* zx translation */
212- {0x06, _sidestepping_left},
213- {0x07, _sidestepping_right},
214-
215- /* as looking */
216- {0x00, _looking_left},
217- {0x01, _looking_right},
218-
219- /* dcv vertical looking */
220- {0x02, _looking_up},
221- {0x08, _looking_down},
222- {0x09, _looking_center},
223-
224- /* ;' for weapon cycling */
225- {0x0c, _cycle_weapons_backward},
226- {0x0d, _cycle_weapons_forward},
227-
228- /* space for primary trigger, option for alternate trigger */
229- {0x31, _left_trigger_state},
230- {0x3a, _right_trigger_state},
231-
232- /* shift, control and command modifiers */
233- {0x37, _sidestep_dont_turn},
234- {0x3b, _run_dont_walk},
235- {0x38, _look_dont_turn},
236-
237- /* tab for action */
238- {0x30, _action_trigger_state},
239-
240- /* m for toggle between normal and overhead map view */
241- {0x2e, _toggle_map},
242-
243- /* ` for using the microphone */
244- {0x32, _microphone_button}
245-#endif
246-};
247-
248-#define NUMBER_OF_POWERBOOK_KEY_DEFINITIONS (sizeof(powerbook_key_definitions)/sizeof(struct key_definition))
249-static struct key_definition powerbook_key_definitions[]=
250-{
251-#ifdef SDL
252- /* olk; */
253- {SDLK_o, _moving_forward},
254- {SDLK_l, _moving_backward},
255- {SDLK_k, _turning_left},
256- {SDLK_SEMICOLON, _turning_right},
257-
258- /* zx translation */
259- {SDLK_z, _sidestepping_left},
260- {SDLK_x, _sidestepping_right},
261-
262- /* as looking */
263- {SDLK_a, _looking_left},
264- {SDLK_s, _looking_right},
265-
266- /* dcv vertical looking */
267- {SDLK_d, _looking_up},
268- {SDLK_c, _looking_down},
269- {SDLK_v, _looking_center},
270-
271- /* ip for weapon cycling */
272- {SDLK_i, _cycle_weapons_backward},
273- {SDLK_p, _cycle_weapons_forward},
274-
275- /* space for primary trigger, option for alternate trigger */
276- {SDLK_SPACE, _left_trigger_state},
277- {SDLK_LALT, _right_trigger_state},
278-
279- /* shift, control and command modifiers */
280- {SDLK_LSHIFT, _sidestep_dont_turn},
281- {SDLK_LCTRL, _run_dont_walk},
282- {SDLK_LMETA, _look_dont_turn},
283-
284- /* tab for action */
285- {SDLK_TAB, _action_trigger_state},
286-
287- /* m for toggle between normal and overhead map view */
288- {SDLK_m, _toggle_map},
289-
290- /* ` for using the microphone */
291- {SDLK_BACKQUOTE, _microphone_button}
292-#else
293- /* olk; */
294- {0x1f, _moving_forward},
295- {0x25, _moving_backward},
296- {0x28, _turning_left},
297- {0x29, _turning_right},
298-
299- /* zx translation */
300- {0x06, _sidestepping_left},
301- {0x07, _sidestepping_right},
302-
303- /* as looking */
304- {0x00, _looking_left},
305- {0x01, _looking_right},
306-
307- /* dcv vertical looking */
308- {0x02, _looking_up},
309- {0x08, _looking_down},
310- {0x09, _looking_center},
311-
312- /* ip for weapon cycling */
313- {0x22, _cycle_weapons_backward},
314- {0x23, _cycle_weapons_forward},
315-
316- /* space for primary trigger, option for alternate trigger */
317- {0x31, _left_trigger_state},
318- {0x3a, _right_trigger_state},
319-
320- /* shift, control and command modifiers */
321- {0x37, _sidestep_dont_turn},
322- {0x3b, _run_dont_walk},
323- {0x38, _look_dont_turn},
324-
325- /* tab for action */
326- {0x30, _action_trigger_state},
327-
328- /* m for toggle between normal and overhead map view */
329- {0x2e, _toggle_map},
330-
331- /* ` for using the microphone */
332- {0x32, _microphone_button}
333-#endif
334-};
335-
336-static struct key_definition *all_key_definitions[NUMBER_OF_KEY_SETUPS]=
337-{
338- standard_key_definitions,
339- left_handed_key_definitions,
340- powerbook_key_definitions
341-};
342-
343-/* Externed because both vbl.c and vbl_macintosh.c use this. */
344-extern struct key_definition current_key_definitions[NUMBER_OF_STANDARD_KEY_DEFINITIONS];
345-
346-#endif
347-
1+#ifndef __KEY_DEFINITIONS_H
2+#define __KEY_DEFINITIONS_H
3+
4+/*
5+
6+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
7+ and the "Aleph One" developers.
8+
9+ This program is free software; you can redistribute it and/or modify
10+ it under the terms of the GNU General Public License as published by
11+ the Free Software Foundation; either version 3 of the License, or
12+ (at your option) any later version.
13+
14+ This program is distributed in the hope that it will be useful,
15+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ GNU General Public License for more details.
18+
19+ This license is contained in the file "COPYING",
20+ which is included with this source code; it is available online at
21+ http://www.gnu.org/licenses/gpl.html
22+
23+*/
24+
25+/*
26+ * Monday, September 12, 1994 12:45:17 PM (alain)
27+ * This header file can only be included by one other file. right now that's vbl.c
28+ *
29+ */
30+
31+
32+/* Constants */
33+enum /* special flag types */
34+{
35+ _double_flag,
36+ _latched_flag
37+};
38+
39+/* Structures */
40+struct blacklist_data
41+{
42+ int16 offset1, offset2; /* the combination of keys that should be blacklisted */
43+ int16 mask1, mask2; /* help for finding them in the keymap */
44+};
45+
46+struct special_flag_data
47+{
48+ int16 type;
49+ int32 flag, alternate_flag;
50+ int16 persistence;
51+};
52+
53+struct key_definition
54+{
55+#ifdef SDL
56+ SDLKey offset;
57+ uint32 action_flag;
58+#else
59+ int16 offset;
60+ int32 action_flag;
61+ int16 mask;
62+#endif
63+};
64+
65+/*
66+ * various key setups that the user can get.
67+ * NOTE that these arrays must all be in the same order, and they must
68+ * be in the same order as the text edit boxes in the "setup keys" dialog
69+ *
70+ */
71+
72+#define NUMBER_OF_STANDARD_KEY_DEFINITIONS (sizeof(standard_key_definitions)/sizeof(struct key_definition))
73+static struct key_definition standard_key_definitions[]=
74+{
75+#ifdef SDL
76+ /* keypad */
77+ {SDLK_KP8, _moving_forward},
78+ {SDLK_KP5, _moving_backward},
79+ {SDLK_KP4, _turning_left},
80+ {SDLK_KP6, _turning_right},
81+
82+ /* zx translation */
83+ {SDLK_z, _sidestepping_left},
84+ {SDLK_x, _sidestepping_right},
85+
86+ /* as looking */
87+ {SDLK_a, _looking_left},
88+ {SDLK_s, _looking_right},
89+
90+ /* dcv vertical looking */
91+ {SDLK_d, _looking_up},
92+ {SDLK_c, _looking_down},
93+ {SDLK_v, _looking_center},
94+
95+ /* KP7/KP9 for weapon cycling */
96+ {SDLK_KP7, _cycle_weapons_backward},
97+ {SDLK_KP9, _cycle_weapons_forward},
98+
99+ /* space for primary trigger, option for alternate trigger */
100+ {SDLK_SPACE, _left_trigger_state},
101+ {SDLK_LALT, _right_trigger_state},
102+
103+ /* shift, control and command modifiers */
104+ {SDLK_LSHIFT, _sidestep_dont_turn},
105+ {SDLK_LCTRL, _run_dont_walk},
106+ {SDLK_LMETA, _look_dont_turn},
107+
108+ /* tab for action */
109+ {SDLK_TAB, _action_trigger_state},
110+
111+ /* m for toggle between normal and overhead map view */
112+ {SDLK_m, _toggle_map},
113+
114+ /* ` for using the microphone */
115+ {SDLK_BACKQUOTE, _microphone_button}
116+#else
117+ /* keypad */
118+ {0x5b, _moving_forward},
119+ {0x57, _moving_backward},
120+ {0x56, _turning_left},
121+ {0x58, _turning_right},
122+
123+ /* zx translation */
124+ {0x06, _sidestepping_left},
125+ {0x07, _sidestepping_right},
126+
127+ /* as looking */
128+ {0x00, _looking_left},
129+ {0x01, _looking_right},
130+
131+ /* dcv vertical looking */
132+ {0x02, _looking_up},
133+ {0x08, _looking_down},
134+ {0x09, _looking_center},
135+
136+ /* KP7/KP9 for weapon cycling */
137+ {0x59, _cycle_weapons_backward},
138+ {0x5c, _cycle_weapons_forward},
139+
140+ /* space for primary trigger, option for alternate trigger */
141+ {0x31, _left_trigger_state},
142+ {0x3a, _right_trigger_state},
143+
144+ /* shift, control and command modifiers */
145+ {0x37, _sidestep_dont_turn},
146+ {0x3b, _run_dont_walk},
147+ {0x38, _look_dont_turn},
148+
149+ /* tab for action */
150+ {0x30, _action_trigger_state},
151+
152+ /* m for toggle between normal and overhead map view */
153+ {0x2e, _toggle_map},
154+
155+ /* ` for using the microphone */
156+ {0x32, _microphone_button}
157+#endif
158+};
159+
160+#define NUMBER_OF_LEFT_HANDED_KEY_DEFINITIONS (sizeof(left_handed_key_definitions)/sizeof(struct key_definition))
161+static struct key_definition left_handed_key_definitions[]=
162+{
163+#ifdef SDL
164+ /* arrows */
165+ {SDLK_UP, _moving_forward},
166+ {SDLK_DOWN, _moving_backward},
167+ {SDLK_LEFT, _turning_left},
168+ {SDLK_RIGHT, _turning_right},
169+
170+ /* zx translation */
171+ {SDLK_z, _sidestepping_left},
172+ {SDLK_x, _sidestepping_right},
173+
174+ /* as looking */
175+ {SDLK_a, _looking_left},
176+ {SDLK_s, _looking_right},
177+
178+ /* dcv vertical looking */
179+ {SDLK_d, _looking_up},
180+ {SDLK_c, _looking_down},
181+ {SDLK_v, _looking_center},
182+
183+ /* ;' for weapon cycling */
184+ {SDLK_SEMICOLON, _cycle_weapons_backward},
185+ {SDLK_QUOTE, _cycle_weapons_forward},
186+
187+ /* space for primary trigger, option for alternate trigger */
188+ {SDLK_SPACE, _left_trigger_state},
189+ {SDLK_LALT, _right_trigger_state},
190+
191+ /* shift, control and command modifiers */
192+ {SDLK_LSHIFT, _sidestep_dont_turn},
193+ {SDLK_LCTRL, _run_dont_walk},
194+ {SDLK_LMETA, _look_dont_turn},
195+
196+ /* tab for action */
197+ {SDLK_TAB, _action_trigger_state},
198+
199+ /* m for toggle between normal and overhead map view */
200+ {SDLK_m, _toggle_map},
201+
202+ /* ` for using the microphone */
203+ {SDLK_BACKQUOTE, _microphone_button}
204+#else
205+ /* arrows */
206+ {0x7e, _moving_forward},
207+ {0x7d, _moving_backward},
208+ {0x7b, _turning_left},
209+ {0x7c, _turning_right},
210+
211+ /* zx translation */
212+ {0x06, _sidestepping_left},
213+ {0x07, _sidestepping_right},
214+
215+ /* as looking */
216+ {0x00, _looking_left},
217+ {0x01, _looking_right},
218+
219+ /* dcv vertical looking */
220+ {0x02, _looking_up},
221+ {0x08, _looking_down},
222+ {0x09, _looking_center},
223+
224+ /* ;' for weapon cycling */
225+ {0x0c, _cycle_weapons_backward},
226+ {0x0d, _cycle_weapons_forward},
227+
228+ /* space for primary trigger, option for alternate trigger */
229+ {0x31, _left_trigger_state},
230+ {0x3a, _right_trigger_state},
231+
232+ /* shift, control and command modifiers */
233+ {0x37, _sidestep_dont_turn},
234+ {0x3b, _run_dont_walk},
235+ {0x38, _look_dont_turn},
236+
237+ /* tab for action */
238+ {0x30, _action_trigger_state},
239+
240+ /* m for toggle between normal and overhead map view */
241+ {0x2e, _toggle_map},
242+
243+ /* ` for using the microphone */
244+ {0x32, _microphone_button}
245+#endif
246+};
247+
248+#define NUMBER_OF_POWERBOOK_KEY_DEFINITIONS (sizeof(powerbook_key_definitions)/sizeof(struct key_definition))
249+static struct key_definition powerbook_key_definitions[]=
250+{
251+#ifdef SDL
252+ /* olk; */
253+ {SDLK_o, _moving_forward},
254+ {SDLK_l, _moving_backward},
255+ {SDLK_k, _turning_left},
256+ {SDLK_SEMICOLON, _turning_right},
257+
258+ /* zx translation */
259+ {SDLK_z, _sidestepping_left},
260+ {SDLK_x, _sidestepping_right},
261+
262+ /* as looking */
263+ {SDLK_a, _looking_left},
264+ {SDLK_s, _looking_right},
265+
266+ /* dcv vertical looking */
267+ {SDLK_d, _looking_up},
268+ {SDLK_c, _looking_down},
269+ {SDLK_v, _looking_center},
270+
271+ /* ip for weapon cycling */
272+ {SDLK_i, _cycle_weapons_backward},
273+ {SDLK_p, _cycle_weapons_forward},
274+
275+ /* space for primary trigger, option for alternate trigger */
276+ {SDLK_SPACE, _left_trigger_state},
277+ {SDLK_LALT, _right_trigger_state},
278+
279+ /* shift, control and command modifiers */
280+ {SDLK_LSHIFT, _sidestep_dont_turn},
281+ {SDLK_LCTRL, _run_dont_walk},
282+ {SDLK_LMETA, _look_dont_turn},
283+
284+ /* tab for action */
285+ {SDLK_TAB, _action_trigger_state},
286+
287+ /* m for toggle between normal and overhead map view */
288+ {SDLK_m, _toggle_map},
289+
290+ /* ` for using the microphone */
291+ {SDLK_BACKQUOTE, _microphone_button}
292+#else
293+ /* olk; */
294+ {0x1f, _moving_forward},
295+ {0x25, _moving_backward},
296+ {0x28, _turning_left},
297+ {0x29, _turning_right},
298+
299+ /* zx translation */
300+ {0x06, _sidestepping_left},
301+ {0x07, _sidestepping_right},
302+
303+ /* as looking */
304+ {0x00, _looking_left},
305+ {0x01, _looking_right},
306+
307+ /* dcv vertical looking */
308+ {0x02, _looking_up},
309+ {0x08, _looking_down},
310+ {0x09, _looking_center},
311+
312+ /* ip for weapon cycling */
313+ {0x22, _cycle_weapons_backward},
314+ {0x23, _cycle_weapons_forward},
315+
316+ /* space for primary trigger, option for alternate trigger */
317+ {0x31, _left_trigger_state},
318+ {0x3a, _right_trigger_state},
319+
320+ /* shift, control and command modifiers */
321+ {0x37, _sidestep_dont_turn},
322+ {0x3b, _run_dont_walk},
323+ {0x38, _look_dont_turn},
324+
325+ /* tab for action */
326+ {0x30, _action_trigger_state},
327+
328+ /* m for toggle between normal and overhead map view */
329+ {0x2e, _toggle_map},
330+
331+ /* ` for using the microphone */
332+ {0x32, _microphone_button}
333+#endif
334+};
335+
336+static struct key_definition *all_key_definitions[NUMBER_OF_KEY_SETUPS]=
337+{
338+ standard_key_definitions,
339+ left_handed_key_definitions,
340+ powerbook_key_definitions
341+};
342+
343+/* Externed because both vbl.c and vbl_macintosh.c use this. */
344+extern struct key_definition current_key_definitions[NUMBER_OF_STANDARD_KEY_DEFINITIONS];
345+
346+#endif
347+
--- marathon/trunk/Source_Files/Misc/carbon_widgets.cpp (revision 525)
+++ marathon/trunk/Source_Files/Misc/carbon_widgets.cpp (revision 526)
@@ -1,304 +1,304 @@
1-
2-/*
3-
4- Copyright (C) 2005 and beyond by the "Aleph One" developers.
5-
6- This program is free software; you can redistribute it and/or modify
7- it under the terms of the GNU General Public License as published by
8- the Free Software Foundation; either version 3 of the License, or
9- (at your option) any later version.
10-
11- This program is distributed in the hope that it will be useful,
12- but WITHOUT ANY WARRANTY; without even the implied warranty of
13- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- GNU General Public License for more details.
15-
16- This license is contained in the file "COPYING",
17- which is included with this source code; it is available online at
18- http://www.gnu.org/licenses/gpl.html
19-
20-*/
21-
22-/*
23- * carbon_widgets.cpp - Widgets for carbon dialogs
24- *
25- */
26-
27-#include "cseries.h"
28-#include "screen_drawing.h"
29-#include "carbon_widgets.h"
30-
31-void SelectorWidget::set_labels (const std::vector<std::string>& labels)
32-{
33- // Possibly should extend to operate on radio groups too?
34-
35- // Get the menu
36- MenuRef Menu = GetControlPopupMenuHandle(m_ctrl);
37- if (!Menu)
38- return;
39-
40- // Get rid of old contents
41- while(CountMenuItems(Menu)) DeleteMenuItem(Menu, 1);
42-
43- // Add in new contents
44- for (std::vector<std::string>::const_iterator it = labels.begin (); it != labels.end (); ++it) {
45- CFStringRef cfstring = CFStringCreateWithCString(NULL, (*it).c_str (), NULL);
46- AppendMenuItemTextWithCFString(Menu, cfstring, 0, 0, NULL);
47- CFRelease(cfstring);
48- }
49-
50- SetControl32BitMaximum(m_ctrl, CountMenuItems(Menu));
51-}
52-
53-void StaticTextWidget::set_text (const std::string& s)
54-{
55- SetControlData(m_ctrl, kControlLabelPart, kControlStaticTextTextTag, s.length (), s.c_str ());
56- Draw1Control (m_ctrl);
57-}
58-
59-void EditTextOrNumberWidget::hide ()
60-{
61- ControlRef focusCtrl;
62- GetKeyboardFocus (GetControlOwner (m_ctrl), &focusCtrl);
63-
64- if (m_ctrl == focusCtrl)
65- ClearKeyboardFocus (GetControlOwner (m_ctrl));
66-
67- if (m_label_widget)
68- m_label_widget->hide ();
69-
70- NIBsControlWidget::hide ();
71-}
72-
73-void EditTextOrNumberWidget::show ()
74-{
75- if (m_label_widget)
76- m_label_widget->show ();
77-
78- NIBsControlWidget::show ();
79-}
80-
81-void EditTextOrNumberWidget::set_label (const std::string& s)
82-{
83- if (m_label_widget)
84- m_label_widget->set_text (s);
85-}
86-
87-void EditTextOrNumberWidget::set_text (const std::string& s)
88-{
89- SetControlData(m_ctrl, kControlEditTextPart, kControlEditTextTextTag, s.length (), s.c_str ());
90- Draw1Control (m_ctrl);
91-}
92-
93-const string EditTextOrNumberWidget::get_text ()
94-{
95- Size size = 0;
96- GetControlDataSize(m_ctrl, kControlEditTextPart, kControlEditTextTextTag, &size);
97-
98- char* buffer = new char[size];
99- GetControlData(m_ctrl, kControlEditTextPart, kControlEditTextTextTag, size, buffer, NULL);
100- return std::string(buffer, size);
101-}
102-
103-void EditNumberWidget::set_value (int value)
104-{
105- NumToString (value, ptemporary);
106- set_text (pstring_to_string (ptemporary));
107-}
108-
109-int EditNumberWidget::get_value ()
110-{
111- long result;
112-
113- copy_string_to_pstring(get_text (), ptemporary);
114- StringToNum(ptemporary, &result);
115- return result;
116-}
117-
118-void FileChooserWidget::set_file (const FileSpecifier& file)
119-{
120- m_file = file;
121-
122- char buffer[256];
123- m_file.GetName (buffer);
124- m_text->set_text (string (buffer));
125-}
126-
127-void FileChooserWidget::choose_file ()
128-{
129- if (m_file.ReadDialog (m_type, m_prompt.c_str ())) {
130- char dummy[256];
131- m_file.GetName (dummy);
132- m_text->set_text (string (dummy));
133- if (m_callback)
134- m_callback ();
135- }
136-}
137-
138-const string ListWidgetValueForItem(const MetaserverPlayerInfo* element)
139- { return element == NULL ? string() : element->name(); }
140-
141-const string ListWidgetValueForItem(const prospective_joiner_info* element)
142- { return pstring_to_string (element->name); }
143-
144-const string ListWidgetValueForItem(const GameListMessage::GameListEntry* element)
145- { return element == NULL ? string() : element->name(); }
146-
147-extern void _get_player_color(size_t color_index, RGBColor *color);
148-
149-// helper for PlayersInGameWidget::pigDrawer
150-static void calculate_box_colors(
151- short color_index,
152- RGBColor *highlight_color,
153- RGBColor *bar_color,
154- RGBColor *shadow_color)
155-{
156- _get_player_color(color_index, highlight_color);
157-
158- bar_color->red = (highlight_color->red * 7) / 10;
159- bar_color->blue = (highlight_color->blue * 7) / 10;
160- bar_color->green = (highlight_color->green * 7) / 10;
161-
162- shadow_color->red = (highlight_color->red * 2) / 10;
163- shadow_color->blue = (highlight_color->blue * 2) / 10;
164- shadow_color->green = (highlight_color->green * 2) / 10;
165-}
166-
167-// helper for PlayersInGameWidget::pigDrawer
168-static void draw_player_box_with_team(
169- Rect *rectangle,
170- short player_index)
171-{
172- const int TEAM_BADGE_WIDTH = 16;
173- const int NAME_BEVEL_SIZE = 4;
174-
175- player_info *player= (player_info *) NetGetPlayerData(player_index);
176- RGBColor highlight_color, bar_color, shadow_color;
177- Rect team_badge, color_badge, text_box;
178- RGBColor old_color;
179- short index;
180-
181- /* Save the color */
182- GetForeColor(&old_color);
183-
184- /* Setup the rectangles.. */
185- team_badge= color_badge= *rectangle;
186- team_badge.right= team_badge.left+TEAM_BADGE_WIDTH;
187- color_badge.left= team_badge.right;
188-
189- /* Determine the colors */
190- calculate_box_colors(player->team, &highlight_color,
191- &bar_color, &shadow_color);
192-
193- /* Erase the team badge area. */
194- RGBForeColor(&bar_color);
195- PaintRect(&team_badge);
196-
197- /* Draw the highlight for this one. */
198- RGBForeColor(&highlight_color);
199- for (index = 0; index < NAME_BEVEL_SIZE; index++)
200- {
201- MoveTo(team_badge.left+index, team_badge.bottom-index);
202- LineTo(team_badge.left+index, team_badge.top+index);
203- LineTo(team_badge.right, team_badge.top+index);
204- }
205-
206- /* Draw the drop shadow.. */
207- RGBForeColor(&shadow_color);
208- for (index = 0; index < NAME_BEVEL_SIZE; index++)
209- {
210- MoveTo(team_badge.left+index, team_badge.bottom-index);
211- LineTo(team_badge.right, team_badge.bottom-index);
212- }
213-
214- /* Now draw the player color. */
215- calculate_box_colors(player->color, &highlight_color,
216- &bar_color, &shadow_color);
217-
218- /* Erase the team badge area. */
219- RGBForeColor(&bar_color);
220- PaintRect(&color_badge);
221-
222- /* Draw the highlight for this one. */
223- RGBForeColor(&highlight_color);
224- for (index = 0; index < NAME_BEVEL_SIZE; index++)
225- {
226- MoveTo(color_badge.left, color_badge.top+index);
227- LineTo(color_badge.right-index, color_badge.top+index);
228- }
229-
230- /* Draw the drop shadow.. */
231- RGBForeColor(&shadow_color);
232- for (index = 0; index < NAME_BEVEL_SIZE; index++)
233- {
234- MoveTo(color_badge.left, color_badge.bottom-index);
235- LineTo(color_badge.right-index, color_badge.bottom-index);
236- LineTo(color_badge.right-index, color_badge.top+index);
237- }
238-
239- /* Finally, draw the name. */
240- text_box= *rectangle;
241- InsetRect(&text_box, NAME_BEVEL_SIZE, NAME_BEVEL_SIZE);
242- CopyPascalStringToC(player->name, temporary);
243- _draw_screen_text(temporary, (screen_rectangle *) &text_box,
244- _center_horizontal|_center_vertical, _net_stats_font, _white_color);
245-
246- /* Restore the color */
247- RGBForeColor(&old_color);
248-}
249-
250-void PlayersInGameWidget::pigDrawer (ControlRef Ctrl, void* ignored)
251-{
252- const int NAME_BOX_HEIGHT = 28;
253- const int NAME_BOX_WIDTH = 114;
254-
255- const int BOX_SPACING = 8;
256-
257- // No need for the window context -- it's assumed
258- Rect Bounds = {0,0,0,0};
259-
260- GetControlBounds(Ctrl, &Bounds);
261-
262- // Draw background and boundary
263- ForeColor(whiteColor);
264- PaintRect(&Bounds);
265- ForeColor(blackColor);
266- FrameRect(&Bounds);
267-
268- // Cribbed from update_player_list_item()
269- FontInfo finfo;
270- GetFontInfo(&finfo);
271- short height = finfo.ascent + finfo.descent + finfo.leading;
272- MoveTo(Bounds.left + 3, Bounds.top+height);
273- short num_players = NetNumberOfPlayerIsValid() ? NetGetNumberOfPlayers() : 0;
274-
275- Rect name_rect;
276- SetRect(&name_rect, Bounds.left, Bounds.top, Bounds.left+NAME_BOX_WIDTH, Bounds.top+NAME_BOX_HEIGHT);
277- for (short i = 0; i < num_players; i++)
278- {
279- draw_player_box_with_team(&name_rect, i);
280- if (!(i % 2))
281- {
282- OffsetRect(&name_rect, NAME_BOX_WIDTH+BOX_SPACING, 0);
283- }
284- else
285- {
286- OffsetRect(&name_rect, -(NAME_BOX_WIDTH+BOX_SPACING), NAME_BOX_HEIGHT + BOX_SPACING);
287- }
288- }
289-}
290-
291-ColourPickerWidget::ColourPickerWidget (ControlRef ctrl)
292- : NIBsControlWidget (ctrl)
293- , m_control_watcher (ctrl)
294-{
295- m_colourDrawer (ctrl, SwatchDrawer, &m_colour);
296- m_colourHitter (ctrl);
297- m_control_watcher.set_callback (boost::bind (&ColourPickerWidget::chooseColour, this));
298-}
299-
300-void ColourPickerWidget::chooseColour ()
301-{
302- copy_string_to_pstring ("You Must Choose:", ptemporary);
303- PickControlColor (m_ctrl, &m_colour, ptemporary);
304-}
1+
2+/*
3+
4+ Copyright (C) 2005 and beyond by the "Aleph One" developers.
5+
6+ This program is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
10+
11+ This program is distributed in the hope that it will be useful,
12+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ GNU General Public License for more details.
15+
16+ This license is contained in the file "COPYING",
17+ which is included with this source code; it is available online at
18+ http://www.gnu.org/licenses/gpl.html
19+
20+*/
21+
22+/*
23+ * carbon_widgets.cpp - Widgets for carbon dialogs
24+ *
25+ */
26+
27+#include "cseries.h"
28+#include "screen_drawing.h"
29+#include "carbon_widgets.h"
30+
31+void SelectorWidget::set_labels (const std::vector<std::string>& labels)
32+{
33+ // Possibly should extend to operate on radio groups too?
34+
35+ // Get the menu
36+ MenuRef Menu = GetControlPopupMenuHandle(m_ctrl);
37+ if (!Menu)
38+ return;
39+
40+ // Get rid of old contents
41+ while(CountMenuItems(Menu)) DeleteMenuItem(Menu, 1);
42+
43+ // Add in new contents
44+ for (std::vector<std::string>::const_iterator it = labels.begin (); it != labels.end (); ++it) {
45+ CFStringRef cfstring = CFStringCreateWithCString(NULL, (*it).c_str (), NULL);
46+ AppendMenuItemTextWithCFString(Menu, cfstring, 0, 0, NULL);
47+ CFRelease(cfstring);
48+ }
49+
50+ SetControl32BitMaximum(m_ctrl, CountMenuItems(Menu));
51+}
52+
53+void StaticTextWidget::set_text (const std::string& s)
54+{
55+ SetControlData(m_ctrl, kControlLabelPart, kControlStaticTextTextTag, s.length (), s.c_str ());
56+ Draw1Control (m_ctrl);
57+}
58+
59+void EditTextOrNumberWidget::hide ()
60+{
61+ ControlRef focusCtrl;
62+ GetKeyboardFocus (GetControlOwner (m_ctrl), &focusCtrl);
63+
64+ if (m_ctrl == focusCtrl)
65+ ClearKeyboardFocus (GetControlOwner (m_ctrl));
66+
67+ if (m_label_widget)
68+ m_label_widget->hide ();
69+
70+ NIBsControlWidget::hide ();
71+}
72+
73+void EditTextOrNumberWidget::show ()
74+{
75+ if (m_label_widget)
76+ m_label_widget->show ();
77+
78+ NIBsControlWidget::show ();
79+}
80+
81+void EditTextOrNumberWidget::set_label (const std::string& s)
82+{
83+ if (m_label_widget)
84+ m_label_widget->set_text (s);
85+}
86+
87+void EditTextOrNumberWidget::set_text (const std::string& s)
88+{
89+ SetControlData(m_ctrl, kControlEditTextPart, kControlEditTextTextTag, s.length (), s.c_str ());
90+ Draw1Control (m_ctrl);
91+}
92+
93+const string EditTextOrNumberWidget::get_text ()
94+{
95+ Size size = 0;
96+ GetControlDataSize(m_ctrl, kControlEditTextPart, kControlEditTextTextTag, &size);
97+
98+ char* buffer = new char[size];
99+ GetControlData(m_ctrl, kControlEditTextPart, kControlEditTextTextTag, size, buffer, NULL);
100+ return std::string(buffer, size);
101+}
102+
103+void EditNumberWidget::set_value (int value)
104+{
105+ NumToString (value, ptemporary);
106+ set_text (pstring_to_string (ptemporary));
107+}
108+
109+int EditNumberWidget::get_value ()
110+{
111+ long result;
112+
113+ copy_string_to_pstring(get_text (), ptemporary);
114+ StringToNum(ptemporary, &result);
115+ return result;
116+}
117+
118+void FileChooserWidget::set_file (const FileSpecifier& file)
119+{
120+ m_file = file;
121+
122+ char buffer[256];
123+ m_file.GetName (buffer);
124+ m_text->set_text (string (buffer));
125+}
126+
127+void FileChooserWidget::choose_file ()
128+{
129+ if (m_file.ReadDialog (m_type, m_prompt.c_str ())) {
130+ char dummy[256];
131+ m_file.GetName (dummy);
132+ m_text->set_text (string (dummy));
133+ if (m_callback)
134+ m_callback ();
135+ }
136+}
137+
138+const string ListWidgetValueForItem(const MetaserverPlayerInfo* element)
139+ { return element == NULL ? string() : element->name(); }
140+
141+const string ListWidgetValueForItem(const prospective_joiner_info* element)
142+ { return pstring_to_string (element->name); }
143+
144+const string ListWidgetValueForItem(const GameListMessage::GameListEntry* element)
145+ { return element == NULL ? string() : element->name(); }
146+
147+extern void _get_player_color(size_t color_index, RGBColor *color);
148+
149+// helper for PlayersInGameWidget::pigDrawer
150+static void calculate_box_colors(
151+ short color_index,
152+ RGBColor *highlight_color,
153+ RGBColor *bar_color,
154+ RGBColor *shadow_color)
155+{
156+ _get_player_color(color_index, highlight_color);
157+
158+ bar_color->red = (highlight_color->red * 7) / 10;
159+ bar_color->blue = (highlight_color->blue * 7) / 10;
160+ bar_color->green = (highlight_color->green * 7) / 10;
161+
162+ shadow_color->red = (highlight_color->red * 2) / 10;
163+ shadow_color->blue = (highlight_color->blue * 2) / 10;
164+ shadow_color->green = (highlight_color->green * 2) / 10;
165+}
166+
167+// helper for PlayersInGameWidget::pigDrawer
168+static void draw_player_box_with_team(
169+ Rect *rectangle,
170+ short player_index)
171+{
172+ const int TEAM_BADGE_WIDTH = 16;
173+ const int NAME_BEVEL_SIZE = 4;
174+
175+ player_info *player= (player_info *) NetGetPlayerData(player_index);
176+ RGBColor highlight_color, bar_color, shadow_color;
177+ Rect team_badge, color_badge, text_box;
178+ RGBColor old_color;
179+ short index;
180+
181+ /* Save the color */
182+ GetForeColor(&old_color);
183+
184+ /* Setup the rectangles.. */
185+ team_badge= color_badge= *rectangle;
186+ team_badge.right= team_badge.left+TEAM_BADGE_WIDTH;
187+ color_badge.left= team_badge.right;
188+
189+ /* Determine the colors */
190+ calculate_box_colors(player->team, &highlight_color,
191+ &bar_color, &shadow_color);
192+
193+ /* Erase the team badge area. */
194+ RGBForeColor(&bar_color);
195+ PaintRect(&team_badge);
196+
197+ /* Draw the highlight for this one. */
198+ RGBForeColor(&highlight_color);
199+ for (index = 0; index < NAME_BEVEL_SIZE; index++)
200+ {
201+ MoveTo(team_badge.left+index, team_badge.bottom-index);
202+ LineTo(team_badge.left+index, team_badge.top+index);
203+ LineTo(team_badge.right, team_badge.top+index);
204+ }
205+
206+ /* Draw the drop shadow.. */
207+ RGBForeColor(&shadow_color);
208+ for (index = 0; index < NAME_BEVEL_SIZE; index++)
209+ {
210+ MoveTo(team_badge.left+index, team_badge.bottom-index);
211+ LineTo(team_badge.right, team_badge.bottom-index);
212+ }
213+
214+ /* Now draw the player color. */
215+ calculate_box_colors(player->color, &highlight_color,
216+ &bar_color, &shadow_color);
217+
218+ /* Erase the team badge area. */
219+ RGBForeColor(&bar_color);
220+ PaintRect(&color_badge);
221+
222+ /* Draw the highlight for this one. */
223+ RGBForeColor(&highlight_color);
224+ for (index = 0; index < NAME_BEVEL_SIZE; index++)
225+ {
226+ MoveTo(color_badge.left, color_badge.top+index);
227+ LineTo(color_badge.right-index, color_badge.top+index);
228+ }
229+
230+ /* Draw the drop shadow.. */
231+ RGBForeColor(&shadow_color);
232+ for (index = 0; index < NAME_BEVEL_SIZE; index++)
233+ {
234+ MoveTo(color_badge.left, color_badge.bottom-index);
235+ LineTo(color_badge.right-index, color_badge.bottom-index);
236+ LineTo(color_badge.right-index, color_badge.top+index);
237+ }
238+
239+ /* Finally, draw the name. */
240+ text_box= *rectangle;
241+ InsetRect(&text_box, NAME_BEVEL_SIZE, NAME_BEVEL_SIZE);
242+ CopyPascalStringToC(player->name, temporary);
243+ _draw_screen_text(temporary, (screen_rectangle *) &text_box,
244+ _center_horizontal|_center_vertical, _net_stats_font, _white_color);
245+
246+ /* Restore the color */
247+ RGBForeColor(&old_color);
248+}
249+
250+void PlayersInGameWidget::pigDrawer (ControlRef Ctrl, void* ignored)
251+{
252+ const int NAME_BOX_HEIGHT = 28;
253+ const int NAME_BOX_WIDTH = 114;
254+
255+ const int BOX_SPACING = 8;
256+
257+ // No need for the window context -- it's assumed
258+ Rect Bounds = {0,0,0,0};
259+
260+ GetControlBounds(Ctrl, &Bounds);
261+
262+ // Draw background and boundary
263+ ForeColor(whiteColor);
264+ PaintRect(&Bounds);
265+ ForeColor(blackColor);
266+ FrameRect(&Bounds);
267+
268+ // Cribbed from update_player_list_item()
269+ FontInfo finfo;
270+ GetFontInfo(&finfo);
271+ short height = finfo.ascent + finfo.descent + finfo.leading;
272+ MoveTo(Bounds.left + 3, Bounds.top+height);
273+ short num_players = NetNumberOfPlayerIsValid() ? NetGetNumberOfPlayers() : 0;
274+
275+ Rect name_rect;
276+ SetRect(&name_rect, Bounds.left, Bounds.top, Bounds.left+NAME_BOX_WIDTH, Bounds.top+NAME_BOX_HEIGHT);
277+ for (short i = 0; i < num_players; i++)
278+ {
279+ draw_player_box_with_team(&name_rect, i);
280+ if (!(i % 2))
281+ {
282+ OffsetRect(&name_rect, NAME_BOX_WIDTH+BOX_SPACING, 0);
283+ }
284+ else
285+ {
286+ OffsetRect(&name_rect, -(NAME_BOX_WIDTH+BOX_SPACING), NAME_BOX_HEIGHT + BOX_SPACING);
287+ }
288+ }
289+}
290+
291+ColourPickerWidget::ColourPickerWidget (ControlRef ctrl)
292+ : NIBsControlWidget (ctrl)
293+ , m_control_watcher (ctrl)
294+{
295+ m_colourDrawer (ctrl, SwatchDrawer, &m_colour);
296+ m_colourHitter (ctrl);
297+ m_control_watcher.set_callback (boost::bind (&ColourPickerWidget::chooseColour, this));
298+}
299+
300+void ColourPickerWidget::chooseColour ()
301+{
302+ copy_string_to_pstring ("You Must Choose:", ptemporary);
303+ PickControlColor (m_ctrl, &m_colour, ptemporary);
304+}
--- marathon/trunk/Source_Files/Misc/binders.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/binders.h (revision 526)
@@ -1,86 +1,86 @@
1-
2-/*
3-
4- Copyright (C) 2006 and beyond by Bungie Studios, Inc.
5- and the "Aleph One" developers.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20-
21-*/
22-
23-#ifndef BINDERS_H
24-#define BINDERS_H
25-
26-#include <list>
27-#include <algorithm>
28-
29-template<typename T>
30-class Bindable
31-{
32-public:
33- virtual T bind_export () = 0;
34- virtual void bind_import (T) = 0;
35-
36- virtual ~Bindable () {}
37-};
38-
39-class ABinder
40-{
41-public:
42- virtual void migrate_first_to_second () = 0;
43- virtual void migrate_second_to_first () = 0;
44-
45- virtual ~ABinder () {}
46-};
47-
48-template<typename T>
49-class Binder : public ABinder
50-{
51-public:
52- Binder (Bindable<T>* t1, Bindable<T>* t2)
53- : thing1 (t1)
54- , thing2 (t2)
55- {}
56-
57- void migrate_first_to_second () { thing2->bind_import (thing1->bind_export ()); }
58- void migrate_second_to_first () { thing1->bind_import (thing2->bind_export ()); }
59-
60-private:
61- Bindable<T>* thing1;
62- Bindable<T>* thing2;
63-};
64-
65-class BinderSet
66-{
67-public:
68- BinderSet () {}
69- ~BinderSet () { for_each (m_list.begin (), m_list.end (), delete_it); }
70-
71- template<typename T>
72- void insert (Bindable<T>* first, Bindable<T>* second)
73- { if (first && second) m_list.push_back (new Binder<T> (first, second)); }
74-
75- void migrate_all_first_to_second () { for_each (m_list.begin (), m_list.end (), call_first_second); }
76- void migrate_all_second_to_first () { for_each (m_list.begin (), m_list.end (), call_second_first); }
77-
78-private:
79- std::list<ABinder*> m_list;
80-
81- static void call_first_second (ABinder* b) { b->migrate_first_to_second (); }
82- static void call_second_first (ABinder* b) { b->migrate_second_to_first (); }
83- static void delete_it (ABinder* b) { delete b; }
84-};
85-
86-#endif
1+
2+/*
3+
4+ Copyright (C) 2006 and beyond by Bungie Studios, Inc.
5+ and the "Aleph One" developers.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+
21+*/
22+
23+#ifndef BINDERS_H
24+#define BINDERS_H
25+
26+#include <list>
27+#include <algorithm>
28+
29+template<typename T>
30+class Bindable
31+{
32+public:
33+ virtual T bind_export () = 0;
34+ virtual void bind_import (T) = 0;
35+
36+ virtual ~Bindable () {}
37+};
38+
39+class ABinder
40+{
41+public:
42+ virtual void migrate_first_to_second () = 0;
43+ virtual void migrate_second_to_first () = 0;
44+
45+ virtual ~ABinder () {}
46+};
47+
48+template<typename T>
49+class Binder : public ABinder
50+{
51+public:
52+ Binder (Bindable<T>* t1, Bindable<T>* t2)
53+ : thing1 (t1)
54+ , thing2 (t2)
55+ {}
56+
57+ void migrate_first_to_second () { thing2->bind_import (thing1->bind_export ()); }
58+ void migrate_second_to_first () { thing1->bind_import (thing2->bind_export ()); }
59+
60+private:
61+ Bindable<T>* thing1;
62+ Bindable<T>* thing2;
63+};
64+
65+class BinderSet
66+{
67+public:
68+ BinderSet () {}
69+ ~BinderSet () { for_each (m_list.begin (), m_list.end (), delete_it); }
70+
71+ template<typename T>
72+ void insert (Bindable<T>* first, Bindable<T>* second)
73+ { if (first && second) m_list.push_back (new Binder<T> (first, second)); }
74+
75+ void migrate_all_first_to_second () { for_each (m_list.begin (), m_list.end (), call_first_second); }
76+ void migrate_all_second_to_first () { for_each (m_list.begin (), m_list.end (), call_second_first); }
77+
78+private:
79+ std::list<ABinder*> m_list;
80+
81+ static void call_first_second (ABinder* b) { b->migrate_first_to_second (); }
82+ static void call_second_first (ABinder* b) { b->migrate_second_to_first (); }
83+ static void delete_it (ABinder* b) { delete b; }
84+};
85+
86+#endif
--- marathon/trunk/Source_Files/Misc/sdl_network.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/sdl_network.h (revision 526)
@@ -1,125 +1,125 @@
1-/*
2- * sdl_network.h - Definitions for SDL implementation of networking
3-
4- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
5- and the "Aleph One" developers.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20-
21- * Definitions for SDL implementation of networking
22- *
23- * (believed to be) Created by Christian Bauer
24- *
25- * Sept-Nov 2001 (Woody Zenfell): split some defs out of here to network_lookup_sdl.h
26- */
27-
28-#ifndef __SDL__NETWORK_H
29-#define __SDL__NETWORK_H
30-
31-#include <SDL_net.h>
32-
33-#include "cseries.h"
34-
35-#include "network.h"
36-
37-
38-/* missing from AppleTalk.h */
39-// ZZZ: note that this determines only the amount of storage allocated for packets, not
40-// the size of actual packets sent. I believe UDP on Ethernet should be able to carry
41-// around 1.5K per packet, not sure of the exact figure off the top of my head though.
42-// Note that the SDL network microphone code is the one sending "big" packets these days.
43-#define ddpMaxData 1500
44-
45-typedef char NetEntityName[32];
46-typedef IPaddress NetAddrBlock;
47-
48-/* ---------- DDPFrame and PacketBuffer (DDP) */
49-
50-struct DDPFrame
51-{
52- uint16 data_size;
53- byte data[ddpMaxData];
54- UDPsocket socket;
55-};
56-typedef struct DDPFrame DDPFrame, *DDPFramePtr;
57-
58-struct DDPPacketBuffer
59-{
60- byte protocolType;
61- NetAddrBlock sourceAddress;
62-
63- uint16 datagramSize;
64- byte datagramData[ddpMaxData];
65-};
66-typedef struct DDPPacketBuffer DDPPacketBuffer, *DDPPacketBufferPtr;
67-
68-/* ---------- ConnectionEnd (ADSP) */
69-
70-struct ConnectionEnd
71-{
72- TCPsocket socket;
73- TCPsocket server_socket;
74- SDLNet_SocketSet server_socket_set;
75-};
76-typedef struct ConnectionEnd ConnectionEnd, *ConnectionEndPtr;
77-
78-/* ---------- types */
79-
80-typedef NetEntityName *NetEntityNamePtr;
81-
82-typedef void (*lookupUpdateProcPtr)(short message, short index);
83-typedef bool (*lookupFilterProcPtr)(NetEntityName *entity, NetAddrBlock *address);
84-typedef void (*PacketHandlerProcPtr)(DDPPacketBufferPtr packet);
85-
86-/* ---------- prototypes/NETWORK.C */
87-
88-short NetState(void);
89-
90-void NetSetServerIdentifier(short identifier);
91-
92-/* for giving to NetLookupOpen() as a filter procedure */
93-bool NetEntityNotInGame(NetEntityName *entity, NetAddrBlock *address);
94-
95-/* ---------- prototypes/NETWORK_NAMES.C */
96-
97-// ZZZ: moved to network_lookup_sdl.h to localize changes.
98-
99-/* ---------- prototypes/NETWORK_LOOKUP.C */
100-
101-// ZZZ: moved to network_lookup_sdl.h to localize changes.
102-
103-/* ---------- prototypes/NETWORK_DDP.C */
104-
105-OSErr NetDDPOpen(void);
106-OSErr NetDDPClose(void);
107-
108-// ZZZ: this is a bit confusing; in the original AppleTalk DDP code, the socket routines
109-// took and returned a socket number, which is a bit like the file descriptor one gets for
110-// a UNIX socket. Now with NETWORK_IP, that portion of the API is used to pass an IP port number.
111-// (The argument to NetDDPCloseSocket() is now ignored, then; we only currently support one open UDP socket.)
112-// NETWORK_IP: *ioPortNumber is in network byte order ("big-endian")
113-OSErr NetDDPOpenSocket(short *ioPortNumber, PacketHandlerProcPtr packetHandler);
114-OSErr NetDDPCloseSocket(short ignored);
115-
116-DDPFramePtr NetDDPNewFrame(void);
117-void NetDDPDisposeFrame(DDPFramePtr frame);
118-
119-OSErr NetDDPSendFrame(DDPFramePtr frame, NetAddrBlock *address, short protocolType, short socket);
120-
121-/* ---------- prototypes/NETWORK_ADSP.C */
122-
123-// jkvw: removed - we use TCPMess now
124-
125-#endif
1+/*
2+ * sdl_network.h - Definitions for SDL implementation of networking
3+
4+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
5+ and the "Aleph One" developers.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+
21+ * Definitions for SDL implementation of networking
22+ *
23+ * (believed to be) Created by Christian Bauer
24+ *
25+ * Sept-Nov 2001 (Woody Zenfell): split some defs out of here to network_lookup_sdl.h
26+ */
27+
28+#ifndef __SDL__NETWORK_H
29+#define __SDL__NETWORK_H
30+
31+#include <SDL_net.h>
32+
33+#include "cseries.h"
34+
35+#include "network.h"
36+
37+
38+/* missing from AppleTalk.h */
39+// ZZZ: note that this determines only the amount of storage allocated for packets, not
40+// the size of actual packets sent. I believe UDP on Ethernet should be able to carry
41+// around 1.5K per packet, not sure of the exact figure off the top of my head though.
42+// Note that the SDL network microphone code is the one sending "big" packets these days.
43+#define ddpMaxData 1500
44+
45+typedef char NetEntityName[32];
46+typedef IPaddress NetAddrBlock;
47+
48+/* ---------- DDPFrame and PacketBuffer (DDP) */
49+
50+struct DDPFrame
51+{
52+ uint16 data_size;
53+ byte data[ddpMaxData];
54+ UDPsocket socket;
55+};
56+typedef struct DDPFrame DDPFrame, *DDPFramePtr;
57+
58+struct DDPPacketBuffer
59+{
60+ byte protocolType;
61+ NetAddrBlock sourceAddress;
62+
63+ uint16 datagramSize;
64+ byte datagramData[ddpMaxData];
65+};
66+typedef struct DDPPacketBuffer DDPPacketBuffer, *DDPPacketBufferPtr;
67+
68+/* ---------- ConnectionEnd (ADSP) */
69+
70+struct ConnectionEnd
71+{
72+ TCPsocket socket;
73+ TCPsocket server_socket;
74+ SDLNet_SocketSet server_socket_set;
75+};
76+typedef struct ConnectionEnd ConnectionEnd, *ConnectionEndPtr;
77+
78+/* ---------- types */
79+
80+typedef NetEntityName *NetEntityNamePtr;
81+
82+typedef void (*lookupUpdateProcPtr)(short message, short index);
83+typedef bool (*lookupFilterProcPtr)(NetEntityName *entity, NetAddrBlock *address);
84+typedef void (*PacketHandlerProcPtr)(DDPPacketBufferPtr packet);
85+
86+/* ---------- prototypes/NETWORK.C */
87+
88+short NetState(void);
89+
90+void NetSetServerIdentifier(short identifier);
91+
92+/* for giving to NetLookupOpen() as a filter procedure */
93+bool NetEntityNotInGame(NetEntityName *entity, NetAddrBlock *address);
94+
95+/* ---------- prototypes/NETWORK_NAMES.C */
96+
97+// ZZZ: moved to network_lookup_sdl.h to localize changes.
98+
99+/* ---------- prototypes/NETWORK_LOOKUP.C */
100+
101+// ZZZ: moved to network_lookup_sdl.h to localize changes.
102+
103+/* ---------- prototypes/NETWORK_DDP.C */
104+
105+OSErr NetDDPOpen(void);
106+OSErr NetDDPClose(void);
107+
108+// ZZZ: this is a bit confusing; in the original AppleTalk DDP code, the socket routines
109+// took and returned a socket number, which is a bit like the file descriptor one gets for
110+// a UNIX socket. Now with NETWORK_IP, that portion of the API is used to pass an IP port number.
111+// (The argument to NetDDPCloseSocket() is now ignored, then; we only currently support one open UDP socket.)
112+// NETWORK_IP: *ioPortNumber is in network byte order ("big-endian")
113+OSErr NetDDPOpenSocket(short *ioPortNumber, PacketHandlerProcPtr packetHandler);
114+OSErr NetDDPCloseSocket(short ignored);
115+
116+DDPFramePtr NetDDPNewFrame(void);
117+void NetDDPDisposeFrame(DDPFramePtr frame);
118+
119+OSErr NetDDPSendFrame(DDPFramePtr frame, NetAddrBlock *address, short protocolType, short socket);
120+
121+/* ---------- prototypes/NETWORK_ADSP.C */
122+
123+// jkvw: removed - we use TCPMess now
124+
125+#endif
--- marathon/trunk/Source_Files/Misc/shared_widgets.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/shared_widgets.h (revision 526)
@@ -1,178 +1,178 @@
1-
2-/*
3-
4- Copyright (C) 2005 and beyond by the "Aleph One" developers.
5-
6- This program is free software; you can redistribute it and/or modify
7- it under the terms of the GNU General Public License as published by
8- the Free Software Foundation; either version 3 of the License, or
9- (at your option) any later version.
10-
11- This program is distributed in the hope that it will be useful,
12- but WITHOUT ANY WARRANTY; without even the implied warranty of
13- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- GNU General Public License for more details.
15-
16- This license is contained in the file "COPYING",
17- which is included with this source code; it is available online at
18- http://www.gnu.org/licenses/gpl.html
19-
20-*/
21-
22-/*
23- * shared_widgets.h - Widgets for carbon and sdl dialogs
24- */
25-
26-// This is where high level widgets with shared implementations on SDL and Carbon go.
27-// Also chooses which target-specific widget header to include.
28-
29-#ifndef SHARED_WIDGETS_H
30-#define SHARED_WIDGETS_H
31-
32-#include "cseries.h"
33-
34-#ifdef SDL
35-#include "sdl_widgets.h"
36-#else
37-#include "carbon_widgets.h"
38-#endif
39-
40-#include "binders.h"
41-
42-class PStringPref : public Bindable<std::string>
43-{
44-public:
45- PStringPref (unsigned char* pref, int length) : m_pref (pref), m_length (length) {};
46-
47- virtual std::string bind_export () { return pstring_to_string (m_pref); }
48- virtual void bind_import (std::string s) { copy_string_to_pstring (s, m_pref, m_length); }
49-
50-protected:
51- unsigned char* m_pref;
52- int m_length;
53-};
54-
55-class CStringPref : public Bindable<std::string>
56-{
57-public:
58- CStringPref (char* pref, int length) : m_pref (pref), m_length (length) {};
59-
60- virtual std::string bind_export () { return string (m_pref); }
61- virtual void bind_import (std::string s) { copy_string_to_cstring (s, m_pref, m_length); }
62-
63-protected:
64- char* m_pref;
65- int m_length;
66-};
67-
68-class BoolPref : public Bindable<bool>
69-{
70-public:
71- BoolPref (bool& pref) : m_pref(pref) {}
72-
73- virtual bool bind_export () { return m_pref; }
74- virtual void bind_import (bool value) { m_pref = value; }
75-
76-protected:
77- bool& m_pref;
78-};
79-
80-class BitPref : public Bindable<bool>
81-{
82-public:
83- BitPref (uint16& pref, uint16 mask, bool invert = false)
84- : m_pref (pref), m_mask (mask), m_invert (invert) {}
85-
86- virtual bool bind_export () { return (m_invert ? !(m_pref & m_mask) : (m_pref & m_mask)); }
87- virtual void bind_import (bool value) { (m_invert ? !value : value) ? m_pref |= m_mask : m_pref &= (m_mask ^ 0xFFFF); }
88-
89-protected:
90- uint16& m_pref;
91- uint16 m_mask;
92- bool m_invert;
93-};
94-
95-class Int16Pref : public Bindable<int>
96-{
97-public:
98- Int16Pref (int16& pref) : m_pref (pref) {}
99-
100- virtual int bind_export () { return m_pref; }
101- virtual void bind_import (int value) { m_pref = value; }
102-
103-protected:
104- int16& m_pref;
105-};
106-
107-#ifdef mac
108-class FilePref : public Bindable<FileSpecifier>
109-{
110-public:
111- FilePref (FSSpec& pref) : m_pref (pref) {}
112-
113- virtual FileSpecifier bind_export () { FileSpecifier f; f.SetSpec (m_pref); return f; }
114- virtual void bind_import (FileSpecifier value) { m_pref = value.GetSpec (); }
115-
116-protected:
117- FSSpec& m_pref;
118-};
119-#else
120-class FilePref : public Bindable<FileSpecifier>
121-{
122-public:
123- // The buffer should be at least 256
124- FilePref (char* pref) : m_pref (pref) {}
125-
126- virtual FileSpecifier bind_export () { FileSpecifier f (m_pref); return f; }
127- virtual void bind_import (FileSpecifier value) { strncpy (m_pref, value.GetPath (), 255); }
128-
129-protected:
130- char* m_pref;
131-};
132-#endif
133-
134-class ChatHistory
135-{
136-public:
137- class NotificationAdapter {
138- public:
139- virtual void contentAdded (const ColoredChatEntry& e) = 0;
140- virtual void contentCleared () = 0;
141- virtual ~NotificationAdapter() {}
142- };
143-
144- ChatHistory () : m_notificationAdapter (NULL) {}
145-
146- void append(const ColoredChatEntry& e);
147- void clear ();
148- const vector<ColoredChatEntry> getHistory() { return m_history; }
149-
150- void setObserver (NotificationAdapter* notificationAdapter)
151- { m_notificationAdapter = notificationAdapter; }
152-
153-private:
154- vector<ColoredChatEntry> m_history;
155- NotificationAdapter* m_notificationAdapter;
156-};
157-
158-class ColorfulChatWidget : ChatHistory::NotificationAdapter
159-{
160-public:
161- ColorfulChatWidget(ColorfulChatWidgetImpl* componentWidget)
162- : m_componentWidget(componentWidget),
163- m_history(NULL)
164- {}
165-
166- virtual ~ColorfulChatWidget();
167-
168- void attachHistory(ChatHistory* history);
169-
170- virtual void contentAdded(const ColoredChatEntry& e);
171- virtual void contentCleared() { m_componentWidget->Clear(); }
172-
173-private:
174- ColorfulChatWidgetImpl* m_componentWidget;
175- ChatHistory* m_history;
176-};
177-
178-#endif
1+
2+/*
3+
4+ Copyright (C) 2005 and beyond by the "Aleph One" developers.
5+
6+ This program is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
10+
11+ This program is distributed in the hope that it will be useful,
12+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ GNU General Public License for more details.
15+
16+ This license is contained in the file "COPYING",
17+ which is included with this source code; it is available online at
18+ http://www.gnu.org/licenses/gpl.html
19+
20+*/
21+
22+/*
23+ * shared_widgets.h - Widgets for carbon and sdl dialogs
24+ */
25+
26+// This is where high level widgets with shared implementations on SDL and Carbon go.
27+// Also chooses which target-specific widget header to include.
28+
29+#ifndef SHARED_WIDGETS_H
30+#define SHARED_WIDGETS_H
31+
32+#include "cseries.h"
33+
34+#ifdef SDL
35+#include "sdl_widgets.h"
36+#else
37+#include "carbon_widgets.h"
38+#endif
39+
40+#include "binders.h"
41+
42+class PStringPref : public Bindable<std::string>
43+{
44+public:
45+ PStringPref (unsigned char* pref, int length) : m_pref (pref), m_length (length) {};
46+
47+ virtual std::string bind_export () { return pstring_to_string (m_pref); }
48+ virtual void bind_import (std::string s) { copy_string_to_pstring (s, m_pref, m_length); }
49+
50+protected:
51+ unsigned char* m_pref;
52+ int m_length;
53+};
54+
55+class CStringPref : public Bindable<std::string>
56+{
57+public:
58+ CStringPref (char* pref, int length) : m_pref (pref), m_length (length) {};
59+
60+ virtual std::string bind_export () { return string (m_pref); }
61+ virtual void bind_import (std::string s) { copy_string_to_cstring (s, m_pref, m_length); }
62+
63+protected:
64+ char* m_pref;
65+ int m_length;
66+};
67+
68+class BoolPref : public Bindable<bool>
69+{
70+public:
71+ BoolPref (bool& pref) : m_pref(pref) {}
72+
73+ virtual bool bind_export () { return m_pref; }
74+ virtual void bind_import (bool value) { m_pref = value; }
75+
76+protected:
77+ bool& m_pref;
78+};
79+
80+class BitPref : public Bindable<bool>
81+{
82+public:
83+ BitPref (uint16& pref, uint16 mask, bool invert = false)
84+ : m_pref (pref), m_mask (mask), m_invert (invert) {}
85+
86+ virtual bool bind_export () { return (m_invert ? !(m_pref & m_mask) : (m_pref & m_mask)); }
87+ virtual void bind_import (bool value) { (m_invert ? !value : value) ? m_pref |= m_mask : m_pref &= (m_mask ^ 0xFFFF); }
88+
89+protected:
90+ uint16& m_pref;
91+ uint16 m_mask;
92+ bool m_invert;
93+};
94+
95+class Int16Pref : public Bindable<int>
96+{
97+public:
98+ Int16Pref (int16& pref) : m_pref (pref) {}
99+
100+ virtual int bind_export () { return m_pref; }
101+ virtual void bind_import (int value) { m_pref = value; }
102+
103+protected:
104+ int16& m_pref;
105+};
106+
107+#ifdef mac
108+class FilePref : public Bindable<FileSpecifier>
109+{
110+public:
111+ FilePref (FSSpec& pref) : m_pref (pref) {}
112+
113+ virtual FileSpecifier bind_export () { FileSpecifier f; f.SetSpec (m_pref); return f; }
114+ virtual void bind_import (FileSpecifier value) { m_pref = value.GetSpec (); }
115+
116+protected:
117+ FSSpec& m_pref;
118+};
119+#else
120+class FilePref : public Bindable<FileSpecifier>
121+{
122+public:
123+ // The buffer should be at least 256
124+ FilePref (char* pref) : m_pref (pref) {}
125+
126+ virtual FileSpecifier bind_export () { FileSpecifier f (m_pref); return f; }
127+ virtual void bind_import (FileSpecifier value) { strncpy (m_pref, value.GetPath (), 255); }
128+
129+protected:
130+ char* m_pref;
131+};
132+#endif
133+
134+class ChatHistory
135+{
136+public:
137+ class NotificationAdapter {
138+ public:
139+ virtual void contentAdded (const ColoredChatEntry& e) = 0;
140+ virtual void contentCleared () = 0;
141+ virtual ~NotificationAdapter() {}
142+ };
143+
144+ ChatHistory () : m_notificationAdapter (NULL) {}
145+
146+ void append(const ColoredChatEntry& e);
147+ void clear ();
148+ const vector<ColoredChatEntry> getHistory() { return m_history; }
149+
150+ void setObserver (NotificationAdapter* notificationAdapter)
151+ { m_notificationAdapter = notificationAdapter; }
152+
153+private:
154+ vector<ColoredChatEntry> m_history;
155+ NotificationAdapter* m_notificationAdapter;
156+};
157+
158+class ColorfulChatWidget : ChatHistory::NotificationAdapter
159+{
160+public:
161+ ColorfulChatWidget(ColorfulChatWidgetImpl* componentWidget)
162+ : m_componentWidget(componentWidget),
163+ m_history(NULL)
164+ {}
165+
166+ virtual ~ColorfulChatWidget();
167+
168+ void attachHistory(ChatHistory* history);
169+
170+ virtual void contentAdded(const ColoredChatEntry& e);
171+ virtual void contentCleared() { m_componentWidget->Clear(); }
172+
173+private:
174+ ColorfulChatWidgetImpl* m_componentWidget;
175+ ChatHistory* m_history;
176+};
177+
178+#endif
--- marathon/trunk/Source_Files/Misc/PlayerImage_sdl.cpp (revision 525)
+++ marathon/trunk/Source_Files/Misc/PlayerImage_sdl.cpp (revision 526)
@@ -1,391 +1,391 @@
1-/*
2- * PlayerImage_sdl.cpp
3-
4- Copyright (C) 2001 and beyond by Woody Zenfell, III
5- and the "Aleph One" developers.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20-
21- */
22-
23-#include "PlayerImage_sdl.h"
24-
25-#include "world.h"
26-#include "player.h"
27-#include "interface.h"
28-#include "shell.h"
29-#include "collection_definition.h"
30-
31-extern short bit_depth;
32-
33-int16 PlayerImage::sNumOutstandingObjects = 0;
34-
35-PlayerImage::~PlayerImage() {
36- if(mLegsSurface != NULL)
37- SDL_FreeSurface(mLegsSurface);
38-
39- if(mTorsoSurface != NULL)
40- SDL_FreeSurface(mTorsoSurface);
41-
42- if(mLegsData != NULL)
43- free(mLegsData);
44-
45- if(mTorsoData != NULL)
46- free(mTorsoData);
47-
48- objectDestroyed();
49-}
50-
51-
52-
53-void
54-PlayerImage::setRandomFlatteringView() {
55- int16 theView;
56- do {
57- theView = local_random() % 8;
58- } while(theView >= 3 && theView <= 5);
59- setView(theView);
60-}
61-
62-
63-
64-void
65-PlayerImage::updateLegsDrawingInfo() {
66- // Remove old data, if applicable
67- if(mLegsSurface != NULL) {
68- SDL_FreeSurface(mLegsSurface);
69- mLegsSurface = NULL;
70- }
71-
72- if(mLegsData != NULL) {
73- free(mLegsData);
74- mLegsData = NULL;
75- }
76-
77- mLegsValid = false;
78-
79- // Get the player shape definitions
80- player_shape_definitions* theShapeDefinitions = get_player_shape_definitions();
81-
82- // tryAgain tells us whether we made any random choices in the loop. If so, a failed effort results in
83- // another trip through the loop (hopefully with different random choices :) ).
84- bool tryAgain = false;
85-
86- // For safety - don't keep looping if we seem not to be finding good data... eventually, give up as invalid.
87- int16 theNumberOfTriesLeft = 100;
88-
89- do {
90- // We're using up one of our attempts...
91- theNumberOfTriesLeft--;
92-
93- // Find the leg action
94- // We use a local here (instead of using the member directly) so we still which things to pick randomly if we loop.
95- int16 theLegsAction = mLegsAction;
96- if(mLegsAction == NONE) {
97- theLegsAction = local_random() % NUMBER_OF_PLAYER_ACTIONS;
98- tryAgain = true;
99- }
100- // If the user fed us a bad value, stop (with invalid data)
101- else if(theLegsAction < 0 || theLegsAction >= NUMBER_OF_PLAYER_ACTIONS)
102- break;
103-
104- // Find the high-level shape index
105- uint16 theLegsHighLevelShapeIndex = theShapeDefinitions->legs[theLegsAction];
106-
107- // Find out how many animation frames there are for the chosen legs
108- shape_animation_data* theLegsAnimationData = get_shape_animation_data(
109- BUILD_DESCRIPTOR(theShapeDefinitions->collection, theLegsHighLevelShapeIndex));
110-
111- // If this failed, either give up or try again
112- if(theLegsAnimationData == NULL)
113- continue;
114-
115- // Find a view for the legs
116- int16 theLegsView = mLegsView;
117- if(theLegsView == NONE) {
118- theLegsView = local_random() % 8;//theLegsAnimationData->number_of_views;
119- tryAgain = true;
120- }
121- else if(theLegsView < 0 || theLegsView >= 8)
122- break;
123-
124- // Find an animation frame
125- int16 theLegsFrame = mLegsFrame;
126- if(theLegsFrame == NONE) {
127- theLegsFrame = local_random() % theLegsAnimationData->frames_per_view;
128- tryAgain = true;
129- }
130- else if(theLegsFrame < 0 || theLegsFrame >= theLegsAnimationData->frames_per_view)
131- break;
132-
133- // Calculate the low-level shape index index
134- uint16 theLegsLowLevelShapeIndexIndex = theLegsAnimationData->frames_per_view * theLegsView + theLegsFrame;
135-
136- // Finally, we can look up the low-level shape index
137- uint16 theLegsLowLevelShapeIndex = theLegsAnimationData->low_level_shape_indexes[theLegsLowLevelShapeIndexIndex];
138-
139- // Find a legs color
140- int16 theLegsColor = mLegsColor;
141- if(theLegsColor == NONE) {
142- theLegsColor = local_random() % 8;
143- tryAgain = true;
144- }
145- else if(theLegsColor < 0 || theLegsColor >= 8)
146- break;
147-
148- low_level_shape_definition *theLegsLowLevelShape =
149- get_low_level_shape_definition(theShapeDefinitions->collection, theLegsLowLevelShapeIndex);
150-
151- if(theLegsLowLevelShape == NULL)
152- continue;
153-
154- // Get the shape surfaces for the given collection, CLUT (according to color/team), and low-level shape index.
155- if (bit_depth == 8) continue;
156- mLegsSurface = get_shape_surface(theLegsLowLevelShapeIndex,
157- BUILD_COLLECTION(theShapeDefinitions->collection, theLegsColor), &mLegsData, mLegsBrightness);
158-
159- if(mLegsSurface == NULL)
160- continue;
161-
162- // Fill in rect information
163- mLegsRect.x = -theLegsLowLevelShape->key_x;
164- mLegsRect.y = -theLegsLowLevelShape->key_y;
165- mLegsRect.w = mLegsSurface->w;
166- mLegsRect.h = mLegsSurface->h;
167-
168- // We're clear. Copy our temporary variables into the data members.
169- mLegsAction = theLegsAction;
170- mLegsView = theLegsView;
171- mLegsFrame = theLegsFrame;
172- mLegsColor = theLegsColor;
173-
174- // We are _valid_. Sweet.
175- mLegsValid = true;
176-
177- // Success - get me outta here!
178- break;
179-
180- } while(tryAgain && theNumberOfTriesLeft > 0);
181-
182- // Valid or not, the legs are no longer dirty.
183- mLegsDirty = false;
184-}
185-
186-
187-
188-void
189-PlayerImage::updateTorsoDrawingInfo() {
190- // Remove old data, if applicable
191- if(mTorsoSurface != NULL) {
192- SDL_FreeSurface(mTorsoSurface);
193- mTorsoSurface = NULL;
194- }
195-
196- if(mTorsoData != NULL) {
197- free(mTorsoData);
198- mTorsoData = NULL;
199- }
200-
201- mTorsoValid = false;
202-
203- // Get the player shape definitions
204- player_shape_definitions* theShapeDefinitions = get_player_shape_definitions();
205-
206- // tryAgain tells us whether we made any random choices in the loop. If so, a failed effort results in
207- // another trip through the loop (hopefully with different random choices :) ).
208- bool tryAgain = false;
209-
210- // For safety - don't keep looping if we seem not to be finding good data... eventually, give up as invalid.
211- int16 theNumberOfTriesLeft = 100;
212-
213- do {
214- // We're using up one of our attempts...
215- theNumberOfTriesLeft--;
216-
217- // Find the torso action
218- // We use a local here (instead of using the member directly) so we still which things to pick randomly if we loop.
219- int16 theTorsoAction = mTorsoAction;
220- if(mTorsoAction == NONE) {
221- theTorsoAction = local_random() % PLAYER_TORSO_WEAPON_ACTION_COUNT;
222- tryAgain = true;
223- }
224- // If the user fed us a bad value, stop (with invalid data)
225- else if(theTorsoAction < 0 || theTorsoAction >= PLAYER_TORSO_WEAPON_ACTION_COUNT)
226- break;
227-
228- // Find a torso pseudo-weapon
229- int16 thePseudoWeapon = mPseudoWeapon;
230- if(mPseudoWeapon == NONE) {
231- thePseudoWeapon = local_random() % PLAYER_TORSO_SHAPE_COUNT;
232- tryAgain = true;
233- }
234- else if(thePseudoWeapon < 0 || thePseudoWeapon >= PLAYER_TORSO_SHAPE_COUNT)
235- break;
236-
237- // Find the high-level shape index
238- uint16 theTorsoHighLevelShapeIndex;
239-
240- switch(theTorsoAction) {
241-
242- case _shape_weapon_firing:
243- theTorsoHighLevelShapeIndex = theShapeDefinitions->firing_torsos[thePseudoWeapon];
244- break;
245-
246- case _shape_weapon_idle:
247- theTorsoHighLevelShapeIndex = theShapeDefinitions->torsos[thePseudoWeapon];
248- break;
249-
250- case _shape_weapon_charging:
251- theTorsoHighLevelShapeIndex = theShapeDefinitions->charging_torsos[thePseudoWeapon];
252- break;
253-
254- default:
255- // This staves off a compiler warning
256- theTorsoHighLevelShapeIndex = 0;
257- assert(false);
258-
259- }
260-
261- // Find out how many animation frames there are for the chosen torso
262- shape_animation_data* theTorsoAnimationData = get_shape_animation_data(
263- BUILD_DESCRIPTOR(theShapeDefinitions->collection, theTorsoHighLevelShapeIndex));
264-
265- // If this failed, either give up or try again
266- if(theTorsoAnimationData == NULL)
267- continue;
268-
269- // Find a view for the torso
270- int16 theTorsoView = mTorsoView;
271- if(theTorsoView == NONE) {
272- theTorsoView = local_random() % 8;//theTorsoAnimationData->number_of_views;
273- tryAgain = true;
274- }
275- else if(theTorsoView < 0 || theTorsoView >= 8)
276- break;
277-
278- // Find an animation frame
279- int16 theTorsoFrame = mTorsoFrame;
280- if(theTorsoFrame == NONE) {
281- theTorsoFrame = local_random() % theTorsoAnimationData->frames_per_view;
282- tryAgain = true;
283- }
284- else if(theTorsoFrame < 0 || theTorsoFrame >= theTorsoAnimationData->frames_per_view)
285- break;
286-
287- // Calculate the low-level shape index index
288- uint16 theTorsoLowLevelShapeIndexIndex = theTorsoAnimationData->frames_per_view * theTorsoView + theTorsoFrame;
289-
290- // Finally, we can look up the low-level shape index
291- uint16 theTorsoLowLevelShapeIndex = theTorsoAnimationData->low_level_shape_indexes[theTorsoLowLevelShapeIndexIndex];
292-
293- // Find a torso color
294- int16 theTorsoColor = mTorsoColor;
295- if(theTorsoColor == NONE) {
296- theTorsoColor = local_random() % 8;
297- tryAgain = true;
298- }
299- else if(theTorsoColor < 0 || theTorsoColor >= 8)
300- break;
301-
302- low_level_shape_definition *theTorsoLowLevelShape =
303- get_low_level_shape_definition(theShapeDefinitions->collection, theTorsoLowLevelShapeIndex);
304-
305- if(theTorsoLowLevelShape == NULL)
306- continue;
307-
308- // Get the shape surfaces for the given collection, CLUT (according to color/team), and low-level shape index.
309- if (bit_depth == 8) continue;
310- mTorsoSurface = get_shape_surface(theTorsoLowLevelShapeIndex,
311- BUILD_COLLECTION(theShapeDefinitions->collection, theTorsoColor), &mTorsoData, mTorsoBrightness);
312-
313- // Argh, it failed. Why don't we wait for backup?
314- if(mTorsoSurface == NULL)
315- continue;
316-
317- // Fill in rect information
318- mTorsoRect.x = -theTorsoLowLevelShape->origin_x;
319- mTorsoRect.y = -theTorsoLowLevelShape->origin_y;
320- mTorsoRect.w = mTorsoSurface->w;
321- mTorsoRect.h = mTorsoSurface->h;
322-
323- // We're clear. Copy our temporary variables into the data members.
324- mTorsoAction = theTorsoAction;
325- mPseudoWeapon = thePseudoWeapon;
326- mTorsoView = theTorsoView;
327- mTorsoFrame = theTorsoFrame;
328- mTorsoColor = theTorsoColor;
329-
330- // We are _valid_. Sweet.
331- mTorsoValid = true;
332-
333- // Success - get me outta here!
334- break;
335-
336- } while(tryAgain && theNumberOfTriesLeft > 0);
337-
338- // Valid or not, the torso is no longer dirty.
339- mTorsoDirty = false;
340-}
341-
342-
343-
344-void
345-PlayerImage::drawAt(SDL_Surface* inSurface, int16 inX, int16 inY) {
346- SDL_Rect theWorkingRect;
347-
348- if(canDrawLegs()) {
349- theWorkingRect = mLegsRect;
350- theWorkingRect.x += inX;
351- theWorkingRect.y += inY;
352-
353- SDL_BlitSurface(mLegsSurface, NULL, inSurface, const_cast<SDL_Rect*>(&theWorkingRect));
354-
355-// printf("legs bottom at %d\n", theWorkingRect.y + theWorkingRect.h);
356- }
357-
358- if(canDrawTorso()) {
359- theWorkingRect = mTorsoRect;
360- theWorkingRect.x += inX;
361- theWorkingRect.y += inY;
362-
363- SDL_BlitSurface(mTorsoSurface, NULL, inSurface, const_cast<SDL_Rect*>(&theWorkingRect));
364-
365-// printf("torso top at %d\n", theWorkingRect.y);
366- }
367-}
368-
369-
370-
371-void
372-PlayerImage::objectCreated() {
373- if(sNumOutstandingObjects == 0) {
374- mark_collection(get_player_shape_definitions()->collection, true);
375- load_collections(false, false);
376- // XXX (ZZZ) ugly hack, making sure we don't load multiple times.
377-// sNumOutstandingObjects++;
378- }
379-
380- sNumOutstandingObjects++;
381-}
382-
383-void
384-PlayerImage::objectDestroyed() {
385- sNumOutstandingObjects--;
386-
387- if(sNumOutstandingObjects == 0) {
388- mark_collection(get_player_shape_definitions()->collection, false);
389- }
390-
391-}
1+/*
2+ * PlayerImage_sdl.cpp
3+
4+ Copyright (C) 2001 and beyond by Woody Zenfell, III
5+ and the "Aleph One" developers.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+
21+ */
22+
23+#include "PlayerImage_sdl.h"
24+
25+#include "world.h"
26+#include "player.h"
27+#include "interface.h"
28+#include "shell.h"
29+#include "collection_definition.h"
30+
31+extern short bit_depth;
32+
33+int16 PlayerImage::sNumOutstandingObjects = 0;
34+
35+PlayerImage::~PlayerImage() {
36+ if(mLegsSurface != NULL)
37+ SDL_FreeSurface(mLegsSurface);
38+
39+ if(mTorsoSurface != NULL)
40+ SDL_FreeSurface(mTorsoSurface);
41+
42+ if(mLegsData != NULL)
43+ free(mLegsData);
44+
45+ if(mTorsoData != NULL)
46+ free(mTorsoData);
47+
48+ objectDestroyed();
49+}
50+
51+
52+
53+void
54+PlayerImage::setRandomFlatteringView() {
55+ int16 theView;
56+ do {
57+ theView = local_random() % 8;
58+ } while(theView >= 3 && theView <= 5);
59+ setView(theView);
60+}
61+
62+
63+
64+void
65+PlayerImage::updateLegsDrawingInfo() {
66+ // Remove old data, if applicable
67+ if(mLegsSurface != NULL) {
68+ SDL_FreeSurface(mLegsSurface);
69+ mLegsSurface = NULL;
70+ }
71+
72+ if(mLegsData != NULL) {
73+ free(mLegsData);
74+ mLegsData = NULL;
75+ }
76+
77+ mLegsValid = false;
78+
79+ // Get the player shape definitions
80+ player_shape_definitions* theShapeDefinitions = get_player_shape_definitions();
81+
82+ // tryAgain tells us whether we made any random choices in the loop. If so, a failed effort results in
83+ // another trip through the loop (hopefully with different random choices :) ).
84+ bool tryAgain = false;
85+
86+ // For safety - don't keep looping if we seem not to be finding good data... eventually, give up as invalid.
87+ int16 theNumberOfTriesLeft = 100;
88+
89+ do {
90+ // We're using up one of our attempts...
91+ theNumberOfTriesLeft--;
92+
93+ // Find the leg action
94+ // We use a local here (instead of using the member directly) so we still which things to pick randomly if we loop.
95+ int16 theLegsAction = mLegsAction;
96+ if(mLegsAction == NONE) {
97+ theLegsAction = local_random() % NUMBER_OF_PLAYER_ACTIONS;
98+ tryAgain = true;
99+ }
100+ // If the user fed us a bad value, stop (with invalid data)
101+ else if(theLegsAction < 0 || theLegsAction >= NUMBER_OF_PLAYER_ACTIONS)
102+ break;
103+
104+ // Find the high-level shape index
105+ uint16 theLegsHighLevelShapeIndex = theShapeDefinitions->legs[theLegsAction];
106+
107+ // Find out how many animation frames there are for the chosen legs
108+ shape_animation_data* theLegsAnimationData = get_shape_animation_data(
109+ BUILD_DESCRIPTOR(theShapeDefinitions->collection, theLegsHighLevelShapeIndex));
110+
111+ // If this failed, either give up or try again
112+ if(theLegsAnimationData == NULL)
113+ continue;
114+
115+ // Find a view for the legs
116+ int16 theLegsView = mLegsView;
117+ if(theLegsView == NONE) {
118+ theLegsView = local_random() % 8;//theLegsAnimationData->number_of_views;
119+ tryAgain = true;
120+ }
121+ else if(theLegsView < 0 || theLegsView >= 8)
122+ break;
123+
124+ // Find an animation frame
125+ int16 theLegsFrame = mLegsFrame;
126+ if(theLegsFrame == NONE) {
127+ theLegsFrame = local_random() % theLegsAnimationData->frames_per_view;
128+ tryAgain = true;
129+ }
130+ else if(theLegsFrame < 0 || theLegsFrame >= theLegsAnimationData->frames_per_view)
131+ break;
132+
133+ // Calculate the low-level shape index index
134+ uint16 theLegsLowLevelShapeIndexIndex = theLegsAnimationData->frames_per_view * theLegsView + theLegsFrame;
135+
136+ // Finally, we can look up the low-level shape index
137+ uint16 theLegsLowLevelShapeIndex = theLegsAnimationData->low_level_shape_indexes[theLegsLowLevelShapeIndexIndex];
138+
139+ // Find a legs color
140+ int16 theLegsColor = mLegsColor;
141+ if(theLegsColor == NONE) {
142+ theLegsColor = local_random() % 8;
143+ tryAgain = true;
144+ }
145+ else if(theLegsColor < 0 || theLegsColor >= 8)
146+ break;
147+
148+ low_level_shape_definition *theLegsLowLevelShape =
149+ get_low_level_shape_definition(theShapeDefinitions->collection, theLegsLowLevelShapeIndex);
150+
151+ if(theLegsLowLevelShape == NULL)
152+ continue;
153+
154+ // Get the shape surfaces for the given collection, CLUT (according to color/team), and low-level shape index.
155+ if (bit_depth == 8) continue;
156+ mLegsSurface = get_shape_surface(theLegsLowLevelShapeIndex,
157+ BUILD_COLLECTION(theShapeDefinitions->collection, theLegsColor), &mLegsData, mLegsBrightness);
158+
159+ if(mLegsSurface == NULL)
160+ continue;
161+
162+ // Fill in rect information
163+ mLegsRect.x = -theLegsLowLevelShape->key_x;
164+ mLegsRect.y = -theLegsLowLevelShape->key_y;
165+ mLegsRect.w = mLegsSurface->w;
166+ mLegsRect.h = mLegsSurface->h;
167+
168+ // We're clear. Copy our temporary variables into the data members.
169+ mLegsAction = theLegsAction;
170+ mLegsView = theLegsView;
171+ mLegsFrame = theLegsFrame;
172+ mLegsColor = theLegsColor;
173+
174+ // We are _valid_. Sweet.
175+ mLegsValid = true;
176+
177+ // Success - get me outta here!
178+ break;
179+
180+ } while(tryAgain && theNumberOfTriesLeft > 0);
181+
182+ // Valid or not, the legs are no longer dirty.
183+ mLegsDirty = false;
184+}
185+
186+
187+
188+void
189+PlayerImage::updateTorsoDrawingInfo() {
190+ // Remove old data, if applicable
191+ if(mTorsoSurface != NULL) {
192+ SDL_FreeSurface(mTorsoSurface);
193+ mTorsoSurface = NULL;
194+ }
195+
196+ if(mTorsoData != NULL) {
197+ free(mTorsoData);
198+ mTorsoData = NULL;
199+ }
200+
201+ mTorsoValid = false;
202+
203+ // Get the player shape definitions
204+ player_shape_definitions* theShapeDefinitions = get_player_shape_definitions();
205+
206+ // tryAgain tells us whether we made any random choices in the loop. If so, a failed effort results in
207+ // another trip through the loop (hopefully with different random choices :) ).
208+ bool tryAgain = false;
209+
210+ // For safety - don't keep looping if we seem not to be finding good data... eventually, give up as invalid.
211+ int16 theNumberOfTriesLeft = 100;
212+
213+ do {
214+ // We're using up one of our attempts...
215+ theNumberOfTriesLeft--;
216+
217+ // Find the torso action
218+ // We use a local here (instead of using the member directly) so we still which things to pick randomly if we loop.
219+ int16 theTorsoAction = mTorsoAction;
220+ if(mTorsoAction == NONE) {
221+ theTorsoAction = local_random() % PLAYER_TORSO_WEAPON_ACTION_COUNT;
222+ tryAgain = true;
223+ }
224+ // If the user fed us a bad value, stop (with invalid data)
225+ else if(theTorsoAction < 0 || theTorsoAction >= PLAYER_TORSO_WEAPON_ACTION_COUNT)
226+ break;
227+
228+ // Find a torso pseudo-weapon
229+ int16 thePseudoWeapon = mPseudoWeapon;
230+ if(mPseudoWeapon == NONE) {
231+ thePseudoWeapon = local_random() % PLAYER_TORSO_SHAPE_COUNT;
232+ tryAgain = true;
233+ }
234+ else if(thePseudoWeapon < 0 || thePseudoWeapon >= PLAYER_TORSO_SHAPE_COUNT)
235+ break;
236+
237+ // Find the high-level shape index
238+ uint16 theTorsoHighLevelShapeIndex;
239+
240+ switch(theTorsoAction) {
241+
242+ case _shape_weapon_firing:
243+ theTorsoHighLevelShapeIndex = theShapeDefinitions->firing_torsos[thePseudoWeapon];
244+ break;
245+
246+ case _shape_weapon_idle:
247+ theTorsoHighLevelShapeIndex = theShapeDefinitions->torsos[thePseudoWeapon];
248+ break;
249+
250+ case _shape_weapon_charging:
251+ theTorsoHighLevelShapeIndex = theShapeDefinitions->charging_torsos[thePseudoWeapon];
252+ break;
253+
254+ default:
255+ // This staves off a compiler warning
256+ theTorsoHighLevelShapeIndex = 0;
257+ assert(false);
258+
259+ }
260+
261+ // Find out how many animation frames there are for the chosen torso
262+ shape_animation_data* theTorsoAnimationData = get_shape_animation_data(
263+ BUILD_DESCRIPTOR(theShapeDefinitions->collection, theTorsoHighLevelShapeIndex));
264+
265+ // If this failed, either give up or try again
266+ if(theTorsoAnimationData == NULL)
267+ continue;
268+
269+ // Find a view for the torso
270+ int16 theTorsoView = mTorsoView;
271+ if(theTorsoView == NONE) {
272+ theTorsoView = local_random() % 8;//theTorsoAnimationData->number_of_views;
273+ tryAgain = true;
274+ }
275+ else if(theTorsoView < 0 || theTorsoView >= 8)
276+ break;
277+
278+ // Find an animation frame
279+ int16 theTorsoFrame = mTorsoFrame;
280+ if(theTorsoFrame == NONE) {
281+ theTorsoFrame = local_random() % theTorsoAnimationData->frames_per_view;
282+ tryAgain = true;
283+ }
284+ else if(theTorsoFrame < 0 || theTorsoFrame >= theTorsoAnimationData->frames_per_view)
285+ break;
286+
287+ // Calculate the low-level shape index index
288+ uint16 theTorsoLowLevelShapeIndexIndex = theTorsoAnimationData->frames_per_view * theTorsoView + theTorsoFrame;
289+
290+ // Finally, we can look up the low-level shape index
291+ uint16 theTorsoLowLevelShapeIndex = theTorsoAnimationData->low_level_shape_indexes[theTorsoLowLevelShapeIndexIndex];
292+
293+ // Find a torso color
294+ int16 theTorsoColor = mTorsoColor;
295+ if(theTorsoColor == NONE) {
296+ theTorsoColor = local_random() % 8;
297+ tryAgain = true;
298+ }
299+ else if(theTorsoColor < 0 || theTorsoColor >= 8)
300+ break;
301+
302+ low_level_shape_definition *theTorsoLowLevelShape =
303+ get_low_level_shape_definition(theShapeDefinitions->collection, theTorsoLowLevelShapeIndex);
304+
305+ if(theTorsoLowLevelShape == NULL)
306+ continue;
307+
308+ // Get the shape surfaces for the given collection, CLUT (according to color/team), and low-level shape index.
309+ if (bit_depth == 8) continue;
310+ mTorsoSurface = get_shape_surface(theTorsoLowLevelShapeIndex,
311+ BUILD_COLLECTION(theShapeDefinitions->collection, theTorsoColor), &mTorsoData, mTorsoBrightness);
312+
313+ // Argh, it failed. Why don't we wait for backup?
314+ if(mTorsoSurface == NULL)
315+ continue;
316+
317+ // Fill in rect information
318+ mTorsoRect.x = -theTorsoLowLevelShape->origin_x;
319+ mTorsoRect.y = -theTorsoLowLevelShape->origin_y;
320+ mTorsoRect.w = mTorsoSurface->w;
321+ mTorsoRect.h = mTorsoSurface->h;
322+
323+ // We're clear. Copy our temporary variables into the data members.
324+ mTorsoAction = theTorsoAction;
325+ mPseudoWeapon = thePseudoWeapon;
326+ mTorsoView = theTorsoView;
327+ mTorsoFrame = theTorsoFrame;
328+ mTorsoColor = theTorsoColor;
329+
330+ // We are _valid_. Sweet.
331+ mTorsoValid = true;
332+
333+ // Success - get me outta here!
334+ break;
335+
336+ } while(tryAgain && theNumberOfTriesLeft > 0);
337+
338+ // Valid or not, the torso is no longer dirty.
339+ mTorsoDirty = false;
340+}
341+
342+
343+
344+void
345+PlayerImage::drawAt(SDL_Surface* inSurface, int16 inX, int16 inY) {
346+ SDL_Rect theWorkingRect;
347+
348+ if(canDrawLegs()) {
349+ theWorkingRect = mLegsRect;
350+ theWorkingRect.x += inX;
351+ theWorkingRect.y += inY;
352+
353+ SDL_BlitSurface(mLegsSurface, NULL, inSurface, const_cast<SDL_Rect*>(&theWorkingRect));
354+
355+// printf("legs bottom at %d\n", theWorkingRect.y + theWorkingRect.h);
356+ }
357+
358+ if(canDrawTorso()) {
359+ theWorkingRect = mTorsoRect;
360+ theWorkingRect.x += inX;
361+ theWorkingRect.y += inY;
362+
363+ SDL_BlitSurface(mTorsoSurface, NULL, inSurface, const_cast<SDL_Rect*>(&theWorkingRect));
364+
365+// printf("torso top at %d\n", theWorkingRect.y);
366+ }
367+}
368+
369+
370+
371+void
372+PlayerImage::objectCreated() {
373+ if(sNumOutstandingObjects == 0) {
374+ mark_collection(get_player_shape_definitions()->collection, true);
375+ load_collections(false, false);
376+ // XXX (ZZZ) ugly hack, making sure we don't load multiple times.
377+// sNumOutstandingObjects++;
378+ }
379+
380+ sNumOutstandingObjects++;
381+}
382+
383+void
384+PlayerImage::objectDestroyed() {
385+ sNumOutstandingObjects--;
386+
387+ if(sNumOutstandingObjects == 0) {
388+ mark_collection(get_player_shape_definitions()->collection, false);
389+ }
390+
391+}
--- marathon/trunk/Source_Files/Misc/PlayerName.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/PlayerName.h (revision 526)
@@ -1,38 +1,38 @@
1-#ifndef _PLAYER_NAME
2-#define _PLAYER_NAME
3-/*
4-
5- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
6- and the "Aleph One" developers.
7-
8- This program is free software; you can redistribute it and/or modify
9- it under the terms of the GNU General Public License as published by
10- the Free Software Foundation; either version 3 of the License, or
11- (at your option) any later version.
12-
13- This program is distributed in the hope that it will be useful,
14- but WITHOUT ANY WARRANTY; without even the implied warranty of
15- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16- GNU General Public License for more details.
17-
18- This license is contained in the file "COPYING",
19- which is included with this source code; it is available online at
20- http://www.gnu.org/licenses/gpl.html
21-
22- Player-name object and parser
23- by Loren Petrich,
24- April 30, 2000
25-
26- This is for handling the default name in netgames
27-*/
28-
29-
30-#include "XML_ElementParser.h"
31-
32-// Get that name
33-unsigned char *GetPlayerName();
34-
35-// Player-name parser: name is "player_name"
36-XML_ElementParser *PlayerName_GetParser();
37-
38-#endif
1+#ifndef _PLAYER_NAME
2+#define _PLAYER_NAME
3+/*
4+
5+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
6+ and the "Aleph One" developers.
7+
8+ This program is free software; you can redistribute it and/or modify
9+ it under the terms of the GNU General Public License as published by
10+ the Free Software Foundation; either version 3 of the License, or
11+ (at your option) any later version.
12+
13+ This program is distributed in the hope that it will be useful,
14+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ GNU General Public License for more details.
17+
18+ This license is contained in the file "COPYING",
19+ which is included with this source code; it is available online at
20+ http://www.gnu.org/licenses/gpl.html
21+
22+ Player-name object and parser
23+ by Loren Petrich,
24+ April 30, 2000
25+
26+ This is for handling the default name in netgames
27+*/
28+
29+
30+#include "XML_ElementParser.h"
31+
32+// Get that name
33+unsigned char *GetPlayerName();
34+
35+// Player-name parser: name is "player_name"
36+XML_ElementParser *PlayerName_GetParser();
37+
38+#endif
--- marathon/trunk/Source_Files/Misc/Scenario.cpp (revision 525)
+++ marathon/trunk/Source_Files/Misc/Scenario.cpp (revision 526)
@@ -1,108 +1,108 @@
1-/*
2-
3- Copyright (C) 2006 and beyond by Bungie Studios, Inc.
4- and the "Aleph One" developers.
5-
6- This program is free software; you can redistribute it and/or modify
7- it under the terms of the GNU General Public License as published by
8- the Free Software Foundation; either version 3 of the License, or
9- (at your option) any later version.
10-
11- This program is distributed in the hope that it will be useful,
12- but WITHOUT ANY WARRANTY; without even the implied warranty of
13- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14- GNU General Public License for more details.
15-
16- This license is contained in the file "COPYING",
17- which is included with this source code; it is available online at
18- http://www.gnu.org/licenses/gpl.html
19-
20- Scenario tag parser
21- by Gregory Smith 2006
22-
23-
24- This is for handling scenario compatibility info
25-*/
26-
27-#include "cseries.h"
28-#include "Scenario.h"
29-
30-Scenario *Scenario::m_instance;
31-
32-Scenario *Scenario::instance()
33-{
34- if (!m_instance) m_instance = new Scenario();
35- return m_instance;
36-}
37-
38-void Scenario::AddCompatible(const string Compatible)
39-{
40- m_compatibleVersions.push_back(string(Compatible, 0, 23));
41-}
42-
43-bool Scenario::IsCompatible(const string Compatible)
44-{
45- if (Compatible == "" || m_id == "") return true;
46- if (Compatible == m_id) return true;
47- for (int i = 0; i < m_compatibleVersions.size(); i++)
48- {
49- if (m_compatibleVersions[i] == Compatible) return true;
50- }
51-
52- return false;
53-}
54-
55-class XML_ScenarioParser : public XML_ElementParser
56-{
57-public:
58- bool HandleAttribute(const char *Tag, const char *Value);
59-
60- XML_ScenarioParser() : XML_ElementParser("scenario") { }
61-};
62-
63-bool XML_ScenarioParser::HandleAttribute(const char *Tag, const char *Value)
64-{
65- if (StringsEqual(Tag, "name"))
66- {
67- Scenario::instance()->SetName(Value);
68- return true;
69- }
70- else if (StringsEqual(Tag, "version"))
71- {
72- Scenario::instance()->SetVersion(Value);
73- return true;
74- }
75- else if (StringsEqual(Tag, "id"))
76- {
77- Scenario::instance()->SetID(Value);
78- return true;
79- }
80-
81- UnrecognizedTag();
82- return false;
83-}
84-
85-class XML_CanJoinParser : public XML_ElementParser
86-{
87-public:
88- bool HandleString(const char *String, int Length);
89-
90- XML_CanJoinParser() : XML_ElementParser("can_join") { }
91-};
92-
93-bool XML_CanJoinParser::HandleString(const char *String, int Length)
94-{
95- Scenario::instance()->AddCompatible(string(String, Length));
96- return true;
97-}
98-
99-static XML_ScenarioParser ScenarioParser;
100-
101-static XML_CanJoinParser CanJoinParser;
102-
103-
104-XML_ElementParser *Scenario_GetParser()
105-{
106- ScenarioParser.AddChild(&CanJoinParser);
107- return &ScenarioParser;
108-}
1+/*
2+
3+ Copyright (C) 2006 and beyond by Bungie Studios, Inc.
4+ and the "Aleph One" developers.
5+
6+ This program is free software; you can redistribute it and/or modify
7+ it under the terms of the GNU General Public License as published by
8+ the Free Software Foundation; either version 3 of the License, or
9+ (at your option) any later version.
10+
11+ This program is distributed in the hope that it will be useful,
12+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ GNU General Public License for more details.
15+
16+ This license is contained in the file "COPYING",
17+ which is included with this source code; it is available online at
18+ http://www.gnu.org/licenses/gpl.html
19+
20+ Scenario tag parser
21+ by Gregory Smith 2006
22+
23+
24+ This is for handling scenario compatibility info
25+*/
26+
27+#include "cseries.h"
28+#include "Scenario.h"
29+
30+Scenario *Scenario::m_instance;
31+
32+Scenario *Scenario::instance()
33+{
34+ if (!m_instance) m_instance = new Scenario();
35+ return m_instance;
36+}
37+
38+void Scenario::AddCompatible(const string Compatible)
39+{
40+ m_compatibleVersions.push_back(string(Compatible, 0, 23));
41+}
42+
43+bool Scenario::IsCompatible(const string Compatible)
44+{
45+ if (Compatible == "" || m_id == "") return true;
46+ if (Compatible == m_id) return true;
47+ for (int i = 0; i < m_compatibleVersions.size(); i++)
48+ {
49+ if (m_compatibleVersions[i] == Compatible) return true;
50+ }
51+
52+ return false;
53+}
54+
55+class XML_ScenarioParser : public XML_ElementParser
56+{
57+public:
58+ bool HandleAttribute(const char *Tag, const char *Value);
59+
60+ XML_ScenarioParser() : XML_ElementParser("scenario") { }
61+};
62+
63+bool XML_ScenarioParser::HandleAttribute(const char *Tag, const char *Value)
64+{
65+ if (StringsEqual(Tag, "name"))
66+ {
67+ Scenario::instance()->SetName(Value);
68+ return true;
69+ }
70+ else if (StringsEqual(Tag, "version"))
71+ {
72+ Scenario::instance()->SetVersion(Value);
73+ return true;
74+ }
75+ else if (StringsEqual(Tag, "id"))
76+ {
77+ Scenario::instance()->SetID(Value);
78+ return true;
79+ }
80+
81+ UnrecognizedTag();
82+ return false;
83+}
84+
85+class XML_CanJoinParser : public XML_ElementParser
86+{
87+public:
88+ bool HandleString(const char *String, int Length);
89+
90+ XML_CanJoinParser() : XML_ElementParser("can_join") { }
91+};
92+
93+bool XML_CanJoinParser::HandleString(const char *String, int Length)
94+{
95+ Scenario::instance()->AddCompatible(string(String, Length));
96+ return true;
97+}
98+
99+static XML_ScenarioParser ScenarioParser;
100+
101+static XML_CanJoinParser CanJoinParser;
102+
103+
104+XML_ElementParser *Scenario_GetParser()
105+{
106+ ScenarioParser.AddChild(&CanJoinParser);
107+ return &ScenarioParser;
108+}
--- marathon/trunk/Source_Files/Misc/progress.cpp (revision 525)
+++ marathon/trunk/Source_Files/Misc/progress.cpp (revision 526)
@@ -1,285 +1,285 @@
1-/*
2- progress.c
3-
4- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
5- and the "Aleph One" developers.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20-
21- Saturday, October 28, 1995 10:56:17 PM- rdm created.
22-
23-Jan 25, 2002 (Br'fin (Jeremy Parsons)):
24- Replaced proc pointers with UPP for Carbon
25- Added accessors for datafields now opaque in Carbon
26-
27-Feb 27, 2002 (Br'fin (Jeremy Parsons)):
28- Reimplemented for Carbon to use a fancy progress bar control
29- Fixed that it wouldn't actually update its window under carbon
30-*/
31-
32-#include "macintosh_cseries.h"
33-#include "progress.h"
34-#include "shell.h"
35-
36-#ifdef USES_NIBS
37- #include "NibsUiHelpers.h"
38-#endif
39-
40-enum {
41- dialogPROGRESS= 10002,
42- iPROGRESS_BAR= 1,
43- iPROGRESS_MESSAGE
44-};
45-
46-#ifdef USES_NIBS
47-
48-const CFStringRef Window_Progress = CFSTR("Progress");
49-
50-// When not in use, this variable will have value NULL
51-WindowRef ProgressWindow = NULL;
52-
53-
54-static void Update()
55-{
56- if (QDIsPortBuffered(GetWindowPort(ProgressWindow)))
57- QDFlushPortBuffer(GetWindowPort(ProgressWindow), NULL);
58-}
59-
60-
61-void open_progress_dialog(size_t message_id, bool)
62-{
63- OSStatus err;
64-
65- err = CreateWindowFromNib(GUI_Nib,Window_Progress,&ProgressWindow);
66-
67- vassert(err == noErr,
68- csprintf(temporary,"CreateWindowFromNib error: %d for the progress window",err));
69-
70- reset_progress_bar();
71-
72- if (message_id == _loading)
73- SetWindowTitleWithCFString(ProgressWindow, CFSTR("Status")); // not "Network Status"
74- set_progress_dialog_message(message_id);
75-
76- ShowWindow(ProgressWindow);
77-}
78-
79-void close_progress_dialog(void)
80-{
81- assert(ProgressWindow);
82-
83- HideWindow(ProgressWindow);
84- DisposeWindow(ProgressWindow);
85-
86- ProgressWindow = NULL;
87-}
88-
89-void set_progress_dialog_message(size_t message_id)
90-{
91- assert(ProgressWindow);
92-
93- getpstr(ptemporary, strPROGRESS_MESSAGES, message_id);
94-
95- ControlRef Ctrl = GetCtrlFromWindow(ProgressWindow, 0, iPROGRESS_MESSAGE);
96- SetStaticPascalText(Ctrl, ptemporary);
97-
98- Draw1Control(Ctrl); // Updates the control's text display
99- Update();
100-}
101-
102-void draw_progress_bar(size_t sent, size_t total)
103-{
104- assert(ProgressWindow);
105-
106- ControlRef Ctrl = GetCtrlFromWindow(ProgressWindow, 0, iPROGRESS_BAR);
107-
108- int CtrlMin = GetControl32BitMinimum(Ctrl);
109- int CtrlMax = GetControl32BitMaximum(Ctrl);
110-
111- int ProportionSent = CtrlMin + ((sent*(CtrlMax-CtrlMin))/total);
112-
113- SetControl32BitValue(Ctrl, ProportionSent);
114-
115- Update();
116-}
117-
118-void reset_progress_bar(void)
119-{
120- assert(ProgressWindow);
121-
122- ControlRef Ctrl = GetCtrlFromWindow(ProgressWindow, 0, iPROGRESS_BAR);
123-
124- Update();
125-}
126-
127-
128-#else
129-
130-/* ------- structures */
131-struct progress_data {
132- DialogPtr dialog;
133- GrafPtr old_port;
134- UserItemUPP progress_bar_upp;
135-#if defined(TARGET_API_MAC_CARBON)
136- ControlRef control;
137-#endif
138-};
139-
140-/* ------ private prototypes */
141-#if !defined(TARGET_API_MAC_CARBON)
142-static pascal void draw_distribute_progress(DialogPtr dialog, short item_num);
143-#endif
144-
145-/* ------ globals */
146-struct progress_data progress_data;
147-
148-/* ------ calls */
149-void open_progress_dialog(
150- size_t message_id)
151-{
152- Rect item_box;
153- short item_type;
154- Handle item_handle;
155-
156- progress_data.dialog= GetNewDialog(dialogPROGRESS, NULL, (WindowPtr) -1);
157- assert(progress_data.dialog);
158-
159-#if defined(TARGET_API_MAC_CARBON)
160-// Carbon code, let's use a progress control!
161- GetDialogItem(progress_data.dialog, iPROGRESS_BAR, &item_type, &item_handle, &item_box);
162- CreateProgressBarControl(GetDialogWindow(progress_data.dialog), &item_box,
163- 0, 0, RECTANGLE_WIDTH(&item_box), // Values: current, min, max
164- false, &progress_data.control);
165- assert(progress_data.control);
166-#else
167-// Old code, draws a pretty plain meter
168- progress_data.progress_bar_upp= NewUserItemUPP(draw_distribute_progress);
169- assert(progress_data.progress_bar_upp);
170-
171- GetPort(&progress_data.old_port);
172- SetPort(GetWindowPort(GetDialogWindow(progress_data.dialog)));
173-
174- GetDialogItem(progress_data.dialog, iPROGRESS_BAR, &item_type, &item_handle, &item_box);
175- SetDialogItem(progress_data.dialog, iPROGRESS_BAR, item_type, (Handle) progress_data.progress_bar_upp, &item_box);
176-#endif
177- /* Set the message.. */
178- set_progress_dialog_message(message_id);
179-
180- ShowWindow(GetDialogWindow(progress_data.dialog));
181- DrawDialog(progress_data.dialog);
182-
183-#if defined(TARGET_API_MAC_CARBON)
184- if (QDIsPortBuffered(GetDialogPort(progress_data.dialog)))
185- QDFlushPortBuffer(GetDialogPort(progress_data.dialog), NULL);
186- // Busy cursor already provided by OSX
187-#else
188- SetCursor(*(GetCursor(watchCursor)));
189-#endif
190-}
191-
192-void set_progress_dialog_message(
193- size_t message_id)
194-{
195- short item_type;
196- Rect bounds;
197- Handle item_handle;
198-
199- assert(progress_data.dialog);
200- GetDialogItem(progress_data.dialog, iPROGRESS_MESSAGE, &item_type, &item_handle, &bounds);
201- getpstr(ptemporary, strPROGRESS_MESSAGES, message_id);
202- SetDialogItemText(item_handle, ptemporary);
203-}
204-
205-void close_progress_dialog(
206- void)
207-{
208- SetPort(progress_data.old_port);
209-
210-#if !defined(TARGET_API_MAC_CARBON)
211- // Unneeded under OSX
212- SetCursor(&qd.arrow);
213-#endif
214-
215-#if defined(TARGET_API_MAC_CARBON)
216- HideWindow(GetDialogWindow(progress_data.dialog));
217- DisposeControl(progress_data.control);
218- DisposeDialog(progress_data.dialog);
219-#else
220- DisposeDialog(progress_data.dialog);
221- DisposeRoutineDescriptor(progress_data.progress_bar_upp);
222-#endif
223-}
224-
225-void draw_progress_bar(
226- size_t sent,
227- size_t total)
228-{
229- Rect bounds;
230- Handle item;
231- short item_type;
232- short width;
233-
234- GetDialogItem(progress_data.dialog, iPROGRESS_BAR, &item_type, &item, &bounds);
235- width= (sent*RECTANGLE_WIDTH(&bounds))/total;
236-
237-#if defined(TARGET_API_MAC_CARBON)
238- SetControlValue(progress_data.control, width);
239-
240- if (QDIsPortBuffered(GetDialogPort(progress_data.dialog)))
241- QDFlushPortBuffer(GetDialogPort(progress_data.dialog), NULL);
242-#else
243- bounds.right= bounds.left+width;
244- RGBForeColor(system_colors+gray15Percent);
245- PaintRect(&bounds);
246- ForeColor(blackColor);
247-#endif
248-}
249-
250-void reset_progress_bar(
251- void)
252-{
253-#if defined(TARGET_API_MAC_CARBON)
254- draw_progress_bar(0, 100);
255-#else
256- draw_distribute_progress(progress_data.dialog, iPROGRESS_BAR);
257-#endif
258-}
259-
260-/* --------- private code */
261-#if !defined(TARGET_API_MAC_CARBON)
262-static pascal void draw_distribute_progress(
263- DialogPtr dialog,
264- short item_num)
265-{
266- Rect item_box;
267- short item_type;
268- Handle item_handle;
269- GrafPtr old_port;
270-
271- GetPort(&old_port);
272- SetPort(GetWindowPort(GetDialogWindow(dialog)));
273-
274- GetDialogItem(dialog, item_num, &item_type, &item_handle, &item_box);
275- PenNormal();
276- RGBForeColor(system_colors+windowHighlight);
277- PaintRect(&item_box);
278- ForeColor(blackColor);
279- InsetRect(&item_box, -1, -1);
280- FrameRect(&item_box);
281-
282- SetPort(old_port);
283-}
284-#endif
285-#endif
1+/*
2+ progress.c
3+
4+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
5+ and the "Aleph One" developers.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+
21+ Saturday, October 28, 1995 10:56:17 PM- rdm created.
22+
23+Jan 25, 2002 (Br'fin (Jeremy Parsons)):
24+ Replaced proc pointers with UPP for Carbon
25+ Added accessors for datafields now opaque in Carbon
26+
27+Feb 27, 2002 (Br'fin (Jeremy Parsons)):
28+ Reimplemented for Carbon to use a fancy progress bar control
29+ Fixed that it wouldn't actually update its window under carbon
30+*/
31+
32+#include "macintosh_cseries.h"
33+#include "progress.h"
34+#include "shell.h"
35+
36+#ifdef USES_NIBS
37+ #include "NibsUiHelpers.h"
38+#endif
39+
40+enum {
41+ dialogPROGRESS= 10002,
42+ iPROGRESS_BAR= 1,
43+ iPROGRESS_MESSAGE
44+};
45+
46+#ifdef USES_NIBS
47+
48+const CFStringRef Window_Progress = CFSTR("Progress");
49+
50+// When not in use, this variable will have value NULL
51+WindowRef ProgressWindow = NULL;
52+
53+
54+static void Update()
55+{
56+ if (QDIsPortBuffered(GetWindowPort(ProgressWindow)))
57+ QDFlushPortBuffer(GetWindowPort(ProgressWindow), NULL);
58+}
59+
60+
61+void open_progress_dialog(size_t message_id, bool)
62+{
63+ OSStatus err;
64+
65+ err = CreateWindowFromNib(GUI_Nib,Window_Progress,&ProgressWindow);
66+
67+ vassert(err == noErr,
68+ csprintf(temporary,"CreateWindowFromNib error: %d for the progress window",err));
69+
70+ reset_progress_bar();
71+
72+ if (message_id == _loading)
73+ SetWindowTitleWithCFString(ProgressWindow, CFSTR("Status")); // not "Network Status"
74+ set_progress_dialog_message(message_id);
75+
76+ ShowWindow(ProgressWindow);
77+}
78+
79+void close_progress_dialog(void)
80+{
81+ assert(ProgressWindow);
82+
83+ HideWindow(ProgressWindow);
84+ DisposeWindow(ProgressWindow);
85+
86+ ProgressWindow = NULL;
87+}
88+
89+void set_progress_dialog_message(size_t message_id)
90+{
91+ assert(ProgressWindow);
92+
93+ getpstr(ptemporary, strPROGRESS_MESSAGES, message_id);
94+
95+ ControlRef Ctrl = GetCtrlFromWindow(ProgressWindow, 0, iPROGRESS_MESSAGE);
96+ SetStaticPascalText(Ctrl, ptemporary);
97+
98+ Draw1Control(Ctrl); // Updates the control's text display
99+ Update();
100+}
101+
102+void draw_progress_bar(size_t sent, size_t total)
103+{
104+ assert(ProgressWindow);
105+
106+ ControlRef Ctrl = GetCtrlFromWindow(ProgressWindow, 0, iPROGRESS_BAR);
107+
108+ int CtrlMin = GetControl32BitMinimum(Ctrl);
109+ int CtrlMax = GetControl32BitMaximum(Ctrl);
110+
111+ int ProportionSent = CtrlMin + ((sent*(CtrlMax-CtrlMin))/total);
112+
113+ SetControl32BitValue(Ctrl, ProportionSent);
114+
115+ Update();
116+}
117+
118+void reset_progress_bar(void)
119+{
120+ assert(ProgressWindow);
121+
122+ ControlRef Ctrl = GetCtrlFromWindow(ProgressWindow, 0, iPROGRESS_BAR);
123+
124+ Update();
125+}
126+
127+
128+#else
129+
130+/* ------- structures */
131+struct progress_data {
132+ DialogPtr dialog;
133+ GrafPtr old_port;
134+ UserItemUPP progress_bar_upp;
135+#if defined(TARGET_API_MAC_CARBON)
136+ ControlRef control;
137+#endif
138+};
139+
140+/* ------ private prototypes */
141+#if !defined(TARGET_API_MAC_CARBON)
142+static pascal void draw_distribute_progress(DialogPtr dialog, short item_num);
143+#endif
144+
145+/* ------ globals */
146+struct progress_data progress_data;
147+
148+/* ------ calls */
149+void open_progress_dialog(
150+ size_t message_id)
151+{
152+ Rect item_box;
153+ short item_type;
154+ Handle item_handle;
155+
156+ progress_data.dialog= GetNewDialog(dialogPROGRESS, NULL, (WindowPtr) -1);
157+ assert(progress_data.dialog);
158+
159+#if defined(TARGET_API_MAC_CARBON)
160+// Carbon code, let's use a progress control!
161+ GetDialogItem(progress_data.dialog, iPROGRESS_BAR, &item_type, &item_handle, &item_box);
162+ CreateProgressBarControl(GetDialogWindow(progress_data.dialog), &item_box,
163+ 0, 0, RECTANGLE_WIDTH(&item_box), // Values: current, min, max
164+ false, &progress_data.control);
165+ assert(progress_data.control);
166+#else
167+// Old code, draws a pretty plain meter
168+ progress_data.progress_bar_upp= NewUserItemUPP(draw_distribute_progress);
169+ assert(progress_data.progress_bar_upp);
170+
171+ GetPort(&progress_data.old_port);
172+ SetPort(GetWindowPort(GetDialogWindow(progress_data.dialog)));
173+
174+ GetDialogItem(progress_data.dialog, iPROGRESS_BAR, &item_type, &item_handle, &item_box);
175+ SetDialogItem(progress_data.dialog, iPROGRESS_BAR, item_type, (Handle) progress_data.progress_bar_upp, &item_box);
176+#endif
177+ /* Set the message.. */
178+ set_progress_dialog_message(message_id);
179+
180+ ShowWindow(GetDialogWindow(progress_data.dialog));
181+ DrawDialog(progress_data.dialog);
182+
183+#if defined(TARGET_API_MAC_CARBON)
184+ if (QDIsPortBuffered(GetDialogPort(progress_data.dialog)))
185+ QDFlushPortBuffer(GetDialogPort(progress_data.dialog), NULL);
186+ // Busy cursor already provided by OSX
187+#else
188+ SetCursor(*(GetCursor(watchCursor)));
189+#endif
190+}
191+
192+void set_progress_dialog_message(
193+ size_t message_id)
194+{
195+ short item_type;
196+ Rect bounds;
197+ Handle item_handle;
198+
199+ assert(progress_data.dialog);
200+ GetDialogItem(progress_data.dialog, iPROGRESS_MESSAGE, &item_type, &item_handle, &bounds);
201+ getpstr(ptemporary, strPROGRESS_MESSAGES, message_id);
202+ SetDialogItemText(item_handle, ptemporary);
203+}
204+
205+void close_progress_dialog(
206+ void)
207+{
208+ SetPort(progress_data.old_port);
209+
210+#if !defined(TARGET_API_MAC_CARBON)
211+ // Unneeded under OSX
212+ SetCursor(&qd.arrow);
213+#endif
214+
215+#if defined(TARGET_API_MAC_CARBON)
216+ HideWindow(GetDialogWindow(progress_data.dialog));
217+ DisposeControl(progress_data.control);
218+ DisposeDialog(progress_data.dialog);
219+#else
220+ DisposeDialog(progress_data.dialog);
221+ DisposeRoutineDescriptor(progress_data.progress_bar_upp);
222+#endif
223+}
224+
225+void draw_progress_bar(
226+ size_t sent,
227+ size_t total)
228+{
229+ Rect bounds;
230+ Handle item;
231+ short item_type;
232+ short width;
233+
234+ GetDialogItem(progress_data.dialog, iPROGRESS_BAR, &item_type, &item, &bounds);
235+ width= (sent*RECTANGLE_WIDTH(&bounds))/total;
236+
237+#if defined(TARGET_API_MAC_CARBON)
238+ SetControlValue(progress_data.control, width);
239+
240+ if (QDIsPortBuffered(GetDialogPort(progress_data.dialog)))
241+ QDFlushPortBuffer(GetDialogPort(progress_data.dialog), NULL);
242+#else
243+ bounds.right= bounds.left+width;
244+ RGBForeColor(system_colors+gray15Percent);
245+ PaintRect(&bounds);
246+ ForeColor(blackColor);
247+#endif
248+}
249+
250+void reset_progress_bar(
251+ void)
252+{
253+#if defined(TARGET_API_MAC_CARBON)
254+ draw_progress_bar(0, 100);
255+#else
256+ draw_distribute_progress(progress_data.dialog, iPROGRESS_BAR);
257+#endif
258+}
259+
260+/* --------- private code */
261+#if !defined(TARGET_API_MAC_CARBON)
262+static pascal void draw_distribute_progress(
263+ DialogPtr dialog,
264+ short item_num)
265+{
266+ Rect item_box;
267+ short item_type;
268+ Handle item_handle;
269+ GrafPtr old_port;
270+
271+ GetPort(&old_port);
272+ SetPort(GetWindowPort(GetDialogWindow(dialog)));
273+
274+ GetDialogItem(dialog, item_num, &item_type, &item_handle, &item_box);
275+ PenNormal();
276+ RGBForeColor(system_colors+windowHighlight);
277+ PaintRect(&item_box);
278+ ForeColor(blackColor);
279+ InsetRect(&item_box, -1, -1);
280+ FrameRect(&item_box);
281+
282+ SetPort(old_port);
283+}
284+#endif
285+#endif
--- marathon/trunk/Source_Files/Misc/MacCheckbox.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/MacCheckbox.h (revision 526)
@@ -1,58 +1,58 @@
1-#ifndef _MAC_CHECKBOX_
2-#define _MAC_CHECKBOX_
3-/*
4-
5- Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
6- and the "Aleph One" developers.
7-
8- This program is free software; you can redistribute it and/or modify
9- it under the terms of the GNU General Public License as published by
10- the Free Software Foundation; either version 3 of the License, or
11- (at your option) any later version.
12-
13- This program is distributed in the hope that it will be useful,
14- but WITHOUT ANY WARRANTY; without even the implied warranty of
15- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16- GNU General Public License for more details.
17-
18- This license is contained in the file "COPYING",
19- which is included with this source code; it is available online at
20- http://www.gnu.org/licenses/gpl.html
21-
22- June 11, 2000 (Loren Petrich)
23-
24- This implements MacOS checkboxes
25-*/
26-
27-
28-class MacCheckbox
29-{
30- // Private stuff
31- ControlHandle CHdl;
32- short Item;
33-
34-public:
35-
36- // Get the item number
37- short GetItem() {return Item;}
38-
39- // State routines; the get one returns which state
40- bool GetState() {return GetControlValue(CHdl);}
41- void SetState(bool State) {SetControlValue(CHdl, State);}
42- void ToggleState() {SetState(!GetState());}
43-
44- // Toggle if the item number matches; return whether there was a match
45- bool ToggleIfHit(short _Item)
46- {bool IsHit = (Item == _Item); if (IsHit) ToggleState(); return IsHit;}
47-
48- // Constructor
49- MacCheckbox(DialogPtr DPtr, short _Item, bool State): Item(_Item)
50- {
51- short ItemType;
52- Rect ItemRect;
53- GetDialogItem(DPtr, Item, &ItemType, (Handle *)&CHdl, &ItemRect);
54- SetState(State);
55- }
56-};
57-
58-#endif
1+#ifndef _MAC_CHECKBOX_
2+#define _MAC_CHECKBOX_
3+/*
4+
5+ Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
6+ and the "Aleph One" developers.
7+
8+ This program is free software; you can redistribute it and/or modify
9+ it under the terms of the GNU General Public License as published by
10+ the Free Software Foundation; either version 3 of the License, or
11+ (at your option) any later version.
12+
13+ This program is distributed in the hope that it will be useful,
14+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ GNU General Public License for more details.
17+
18+ This license is contained in the file "COPYING",
19+ which is included with this source code; it is available online at
20+ http://www.gnu.org/licenses/gpl.html
21+
22+ June 11, 2000 (Loren Petrich)
23+
24+ This implements MacOS checkboxes
25+*/
26+
27+
28+class MacCheckbox
29+{
30+ // Private stuff
31+ ControlHandle CHdl;
32+ short Item;
33+
34+public:
35+
36+ // Get the item number
37+ short GetItem() {return Item;}
38+
39+ // State routines; the get one returns which state
40+ bool GetState() {return GetControlValue(CHdl);}
41+ void SetState(bool State) {SetControlValue(CHdl, State);}
42+ void ToggleState() {SetState(!GetState());}
43+
44+ // Toggle if the item number matches; return whether there was a match
45+ bool ToggleIfHit(short _Item)
46+ {bool IsHit = (Item == _Item); if (IsHit) ToggleState(); return IsHit;}
47+
48+ // Constructor
49+ MacCheckbox(DialogPtr DPtr, short _Item, bool State): Item(_Item)
50+ {
51+ short ItemType;
52+ Rect ItemRect;
53+ GetDialogItem(DPtr, Item, &ItemType, (Handle *)&CHdl, &ItemRect);
54+ SetState(State);
55+ }
56+};
57+
58+#endif
--- marathon/trunk/Source_Files/Misc/Logging_gruntwork.h (revision 525)
+++ marathon/trunk/Source_Files/Misc/Logging_gruntwork.h (revision 526)
@@ -1,167 +1,167 @@
1-/*
2-LOGGING_GRUNTWORK.H
3-
4- Copyright (C) 2003 and beyond by Woody Zenfell, III
5- and the "Aleph One" developers.
6-
7- This program is free software; you can redistribute it and/or modify
8- it under the terms of the GNU General Public License as published by
9- the Free Software Foundation; either version 3 of the License, or
10- (at your option) any later version.
11-
12- This program is distributed in the hope that it will be useful,
13- but WITHOUT ANY WARRANTY; without even the implied warranty of
14- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- GNU General Public License for more details.
16-
17- This license is contained in the file "COPYING",
18- which is included with this source code; it is available online at
19- http://www.gnu.org/licenses/gpl.html
20-
21-*/
22-
23-
24-// This file is automatically generated by aleph/tools/gen-Logging_gruntwork.csh
25-// Make changes to that script, not to this file.
26-
27-#if 0
28-// Straight main-thread logging convenience macros
29-#define logFatal(message) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message)))
30-#define logError(message) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message)))
31-#define logWarning(message) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message)))
32-#define logAnomaly(message) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message)))
33-#define logNote(message) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message)))
34-#define logSummary(message) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message)))
35-#define logTrace(message) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message)))
36-#define logDump(message) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message)))
37-#else
38-// this obsoletes this whole file, pretty much - since macros can support var args and stuff :P
39-#define logFatal(...) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, __VA_ARGS__))
40-#define logError(...) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, __VA_ARGS__))
41-#define logWarning(...) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, __VA_ARGS__))
42-#define logAnomaly(...) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, __VA_ARGS__))
43-#define logNote(...) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, __VA_ARGS__))
44-#define logSummary(...) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, __VA_ARGS__))
45-#define logTrace(...) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, __VA_ARGS__))
46-#define logDump(...) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, __VA_ARGS__))
47-#endif
48-
49-
50-#define logFatal1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1)))
51-#define logError1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1)))
52-#define logWarning1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1)))
53-#define logAnomaly1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1)))
54-#define logNote1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1)))
55-#define logSummary1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1)))
56-#define logTrace1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1)))
57-#define logDump1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1)))
58-
59-#define logFatal2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
60-#define logError2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
61-#define logWarning2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
62-#define logAnomaly2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
63-#define logNote2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
64-#define logSummary2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
65-#define logTrace2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
66-#define logDump2(message, arg1, arg2) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
67-
68-#define logFatal3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
69-#define logError3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
70-#define logWarning3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
71-#define logAnomaly3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
72-#define logNote3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
73-#define logSummary3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
74-#define logTrace3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
75-#define logDump3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
76-
77-#define logFatal4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
78-#define logError4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
79-#define logWarning4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
80-#define logAnomaly4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
81-#define logNote4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
82-#define logSummary4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
83-#define logTrace4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
84-#define logDump4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
85-
86-#define logFatal5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
87-#define logError5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
88-#define logWarning5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
89-#define logAnomaly5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
90-#define logNote5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
91-#define logSummary5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
92-#define logTrace5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
93-#define logDump5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
94-
95-
96-// Analogues to the above, but use these when you might be running in a non-main thread
97-#define logFatalNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logFatalLevel, __FILE__, __LINE__, (message)))
98-#define logErrorNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logErrorLevel, __FILE__, __LINE__, (message)))
99-#define logWarningNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logWarningLevel, __FILE__, __LINE__, (message)))
100-#define logAnomalyNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message)))
101-#define logNoteNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logNoteLevel, __FILE__, __LINE__, (message)))
102-#define logSummaryNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logSummaryLevel, __FILE__, __LINE__, (message)))
103-#define logTraceNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logTraceLevel, __FILE__, __LINE__, (message)))
104-#define logDumpNMT(message) (GetCurrentLogger()->logMessageNMT(logDomain, logDumpLevel, __FILE__, __LINE__, (message)))
105-
106-#define logFatalNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1)))
107-#define logErrorNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1)))
108-#define logWarningNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1)))
109-#define logAnomalyNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1)))
110-#define logNoteNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1)))
111-#define logSummaryNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1)))
112-#define logTraceNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1)))
113-#define logDumpNMT1(message, arg1) (GetCurrentLogger()->logMessageNMT(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1)))
114-
115-#define logFatalNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
116-#define logErrorNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
117-#define logWarningNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
118-#define logAnomalyNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
119-#define logNoteNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
120-#define logSummaryNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
121-#define logTraceNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
122-#define logDumpNMT2(message, arg1, arg2) (GetCurrentLogger()->logMessageNMT(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2)))
123-
124-#define logFatalNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
125-#define logErrorNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
126-#define logWarningNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
127-#define logAnomalyNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
128-#define logNoteNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
129-#define logSummaryNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
130-#define logTraceNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
131-#define logDumpNMT3(message, arg1, arg2, arg3) (GetCurrentLogger()->logMessageNMT(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3)))
132-
133-#define logFatalNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
134-#define logErrorNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
135-#define logWarningNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
136-#define logAnomalyNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
137-#define logNoteNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
138-#define logSummaryNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
139-#define logTraceNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
140-#define logDumpNMT4(message, arg1, arg2, arg3, arg4) (GetCurrentLogger()->logMessageNMT(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4)))
141-
142-#define logFatalNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
143-#define logErrorNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
144-#define logWarningNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
145-#define logAnomalyNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
146-#define logNoteNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logNoteLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
147-#define logSummaryNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logSummaryLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
148-#define logTraceNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logTraceLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
149-#define logDumpNMT5(message, arg1, arg2, arg3, arg4, arg5) (GetCurrentLogger()->logMessageNMT(logDomain, logDumpLevel, __FILE__, __LINE__, (message), (arg1), (arg2), (arg3), (arg4), (arg5)))
150-
151-
152-// Main-thread log context convenience macros
153-#define logContext(context) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(false, __FILE__, __LINE__, (context))
154-#define logContext1(context, arg1) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(false, __FILE__, __LINE__, (context), (arg1))
155-#define logContext2(context, arg1, arg2) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(false, __FILE__, __LINE__, (context), (arg1), (arg2))
156-#define logContext3(context, arg1, arg2, arg3) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(false, __FILE__, __LINE__, (context), (arg1), (arg2), (arg3))
157-#define logContext4(context, arg1, arg2, arg3, arg4) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(false, __FILE__, __LINE__, (context), (arg1), (arg2), (arg3), (arg4))
158-#define logContext5(context, arg1, arg2, arg3, arg4, arg5) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(false, __FILE__, __LINE__, (context), (arg1), (arg2), (arg3), (arg4), (arg5))
159-
160-// Non-main-thread analogues to the above
161-#define logContextNMT(context) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(true, __FILE__, __LINE__, (context))
162-#define logContextNMT1(context, arg1) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(true, __FILE__, __LINE__, (context), (arg1))
163-#define logContextNMT2(context, arg1, arg2) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(true, __FILE__, __LINE__, (context), (arg1), (arg2))
164-#define logContextNMT3(context, arg1, arg2, arg3) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(true, __FILE__, __LINE__, (context), (arg1), (arg2), (arg3))
165-#define logContextNMT4(context, arg1, arg2, arg3, arg4) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(true, __FILE__, __LINE__, (context), (arg1), (arg2), (arg3), (arg4))
166-#define logContextNMT5(context, arg1, arg2, arg3, arg4, arg5) LogContext makeUniqueIdentifier(_theLogContext,__LINE__)(true, __FILE__, __LINE__, (context), (arg1), (arg2), (arg3), (arg4), (arg5))
167-
1+/*
2+LOGGING_GRUNTWORK.H
3+
4+ Copyright (C) 2003 and beyond by Woody Zenfell, III
5+ and the "Aleph One" developers.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 3 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ This license is contained in the file "COPYING",
18+ which is included with this source code; it is available online at
19+ http://www.gnu.org/licenses/gpl.html
20+
21+*/
22+
23+
24+// This file is automatically generated by aleph/tools/gen-Logging_gruntwork.csh
25+// Make changes to that script, not to this file.
26+
27+#if 0
28+// Straight main-thread logging convenience macros
29+#define logFatal(message) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message)))
30+#define logError(message) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message)))
31+#define logWarning(message) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message)))
32+#define logAnomaly(message) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, (message)))
33+#define logNote(message) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, (message)))
34+#define logSummary(message) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, (message)))
35+#define logTrace(message) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, (message)))
36+#define logDump(message) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, (message)))
37+#else
38+// this obsoletes this whole file, pretty much - since macros can support var args and stuff :P
39+#define logFatal(...) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, __VA_ARGS__))
40+#define logError(...) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, __VA_ARGS__))
41+#define logWarning(...) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, __VA_ARGS__))
42+#define logAnomaly(...) (GetCurrentLogger()->logMessage(logDomain, logAnomalyLevel, __FILE__, __LINE__, __VA_ARGS__))
43+#define logNote(...) (GetCurrentLogger()->logMessage(logDomain, logNoteLevel, __FILE__, __LINE__, __VA_ARGS__))
44+#define logSummary(...) (GetCurrentLogger()->logMessage(logDomain, logSummaryLevel, __FILE__, __LINE__, __VA_ARGS__))
45+#define logTrace(...) (GetCurrentLogger()->logMessage(logDomain, logTraceLevel, __FILE__, __LINE__, __VA_ARGS__))
46+#define logDump(...) (GetCurrentLogger()->logMessage(logDomain, logDumpLevel, __FILE__, __LINE__, __VA_ARGS__))
47+#endif
48+
49+
50+#define logFatal1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logFatalLevel, __FILE__, __LINE__, (message), (arg1)))
51+#define logError1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logErrorLevel, __FILE__, __LINE__, (message), (arg1)))
52+#define logWarning1(message, arg1) (GetCurrentLogger()->logMessage(logDomain, logWarningLevel, __FILE__, __LINE__, (message), (arg1)))
53<