summaryrefslogtreecommitdiff
path: root/3dc/avp/support
diff options
context:
space:
mode:
Diffstat (limited to '3dc/avp/support')
-rw-r--r--3dc/avp/support/COORDSTR.CPP730
-rw-r--r--3dc/avp/support/COORDSTR.HPP264
-rw-r--r--3dc/avp/support/DAEMON.CPP418
-rw-r--r--3dc/avp/support/command.hpp60
-rw-r--r--3dc/avp/support/consbind.cpp946
-rw-r--r--3dc/avp/support/consbind.hpp201
-rw-r--r--3dc/avp/support/consbtch.cpp217
-rw-r--r--3dc/avp/support/consbtch.hpp56
-rw-r--r--3dc/avp/support/daemon.h152
-rw-r--r--3dc/avp/support/dcontext.hpp60
-rw-r--r--3dc/avp/support/expvar.hpp147
-rw-r--r--3dc/avp/support/indexfnt.cpp1336
-rw-r--r--3dc/avp/support/indexfnt.hpp540
-rw-r--r--3dc/avp/support/ourbool.h38
-rw-r--r--3dc/avp/support/r2base.cpp269
-rw-r--r--3dc/avp/support/r2base.h638
-rw-r--r--3dc/avp/support/r2pos666.cpp106
-rw-r--r--3dc/avp/support/r2pos666.hpp79
-rw-r--r--3dc/avp/support/rebitems.cpp870
-rw-r--r--3dc/avp/support/rebitems.hpp358
-rw-r--r--3dc/avp/support/rebmenus.cpp1722
-rw-r--r--3dc/avp/support/rebmenus.hpp981
-rw-r--r--3dc/avp/support/reflist.cpp17
-rw-r--r--3dc/avp/support/reflist.hpp174
-rw-r--r--3dc/avp/support/refobj.cpp339
-rw-r--r--3dc/avp/support/refobj.hpp201
-rw-r--r--3dc/avp/support/rentrntq.cpp294
-rw-r--r--3dc/avp/support/rentrntq.h71
-rw-r--r--3dc/avp/support/scstring.cpp1973
-rw-r--r--3dc/avp/support/scstring.hpp271
-rw-r--r--3dc/avp/support/strtab.cpp160
-rw-r--r--3dc/avp/support/strtab.hpp81
-rw-r--r--3dc/avp/support/strutil.c834
-rw-r--r--3dc/avp/support/strutil.h138
-rw-r--r--3dc/avp/support/tallfont.cpp1709
-rw-r--r--3dc/avp/support/tallfont.hpp344
-rw-r--r--3dc/avp/support/trig666.cpp182
-rw-r--r--3dc/avp/support/trig666.hpp103
-rw-r--r--3dc/avp/support/vssver.sccbin672 -> 0 bytes
-rw-r--r--3dc/avp/support/wrapstr.cpp372
-rw-r--r--3dc/avp/support/wrapstr.hpp99
41 files changed, 0 insertions, 17550 deletions
diff --git a/3dc/avp/support/COORDSTR.CPP b/3dc/avp/support/COORDSTR.CPP
deleted file mode 100644
index 92d983f..0000000
--- a/3dc/avp/support/COORDSTR.CPP
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
-
- COORDSTR.CPP
-
- Coordinates with strategies
-
-*/
- #include "3dc.h"
- #include "inline.h"
-
- #include "coordstr.hpp"
-
-#if 0
- #include "davemcro.h"
- #include "scrobj.hpp"
-#endif
-
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-#if 0
- static CoordinateWithStrategy* CoordinateWithStrategy::pCWS_FirstActive = NULL;
-#endif
-
- #define INT_SECONDS_FOR_STANDARD_HOMING (0.25)
- #define FIXP_SECONDS_FOR_STANDARD_HOMING (ONE_FIXED * INT_SECONDS_FOR_STANDARD_HOMING)
-
- #define DAVEMCRO_NONZERO_AND_OPPOSITESIGN(Int1, Int2) \
- ( \
- ( \
- ((Int1) > 0) \
- && \
- ((Int2) < 0) \
- ) \
- || \
- ( \
- ((Int1) < 0) \
- && \
- ((Int2) > 0) \
- ) \
- )
-
-
-
-CoordinateWithStrategy::CoordinateWithStrategy
-(
- int Int_InitialCoord,
- OurBool fActive
-) : Daemon
- (
- fActive
- )
-{
- Int_CurrentCoord_Val = Int_InitialCoord;
-}
-
-
-CoordinateWithStrategy::~CoordinateWithStrategy
-(
-)
-{
-}
-
-
-int CoordinateWithStrategy::GetCoord_Int(void)
-{
- return(Int_CurrentCoord_Val);
-}
-
-void CoordinateWithStrategy::SetCoord_Int(int Int_NewCoord)
-{
- Int_CurrentCoord_Val = Int_NewCoord;
-}
-
-
-// Coordinates with velocity ///////////////////////////////////////////////
-CoordinateWithVelocity :: CoordinateWithVelocity
-(
- int Int_InitialCoord,
- int FixP_Velocity,
- OurBool fActive
-) : CoordinateWithStrategy
- (
- Int_InitialCoord,
- fActive
- )
-{
- FixP_Velocity_Val = FixP_Velocity;
- FixP_Position_Val = OUR_INT_TO_FIXED( Int_CurrentCoord_Val );
-}
-
-CoordinateWithVelocity :: ~CoordinateWithVelocity()
-{
- // empty
-}
-
-void CoordinateWithVelocity :: SetCoord_Int
-(
- int Int_NewCoord
-)
-{
- Int_CurrentCoord_Val = Int_NewCoord;
- FixP_Position_Val = OUR_INT_TO_FIXED( Int_CurrentCoord_Val );
-}
-
-void CoordinateWithVelocity :: SetCoord_FixP
-(
- int FixP_NewCoord
-)
-{
- Int_CurrentCoord_Val = OUR_FIXED_TO_INT( FixP_NewCoord );
- FixP_Position_Val = FixP_NewCoord;
-}
-
-void CoordinateWithVelocity :: SetVelocity_FixP(int FixP_NewVelocity)
-{
- FixP_Velocity_Val = FixP_NewVelocity;
-}
-
-
-void CoordinateWithVelocity :: ApplyVelocity
-(
- int FixP_Time
-)
-{
- FixP_Position_Val += MUL_FIXED(FixP_Time, FixP_Velocity_Val);
-
- Int_CurrentCoord_Val = OUR_FIXED_TO_INT( FixP_Position_Val );
-}
-
-int CoordinateWithVelocity :: GetCoord_Int_RoundedUp(void)
-{
-
- int ReturnVal = (FixP_Position_Val >> 16);
-
- if ( (FixP_Position_Val&0xffff) )
- {
- ReturnVal++;
- }
-
- #if 0
- textprint
- (
- "CoordinateWithVelocity :: GetCoord_Int_RoundedUp()\n"
- "FixP_Position_Val = %i\n"
- "ReturnVal = %i\n",
- FixP_Position_Val,
- ReturnVal
- );
- #endif
-
- return ReturnVal;
-}
-
-// Coordinates with velocity: pulsing /////////////////////////////////////////////
-PulsingCoordinate :: PulsingCoordinate
-(
- int Int_InitialCoord,
- int Int_SecondCoord,
- int FixP_Velocity,
- OurBool fActive
-) : CoordinateWithVelocity
- (
- Int_InitialCoord,
- FixP_Velocity,
- fActive
- )
-{
- Int_Target0_Val = Int_InitialCoord;
- FixP_Target0_Val = OUR_INT_TO_FIXED( Int_Target0_Val );
-
- Int_Target1_Val = Int_SecondCoord;
- FixP_Target1_Val = OUR_INT_TO_FIXED( Int_Target1_Val );
-
-}
-
-PulsingCoordinate :: ~PulsingCoordinate()
-{
- // empty
-}
-
-// Pulsing coordinates: acyclic ///////////////////////////////////////////////////
-AcyclicPulsingCoordinate :: AcyclicPulsingCoordinate
-(
- int Int_InitialCoord,
- int Int_SecondCoord,
- int FixP_Velocity,
- OurBool fActive
-) : PulsingCoordinate
- (
- Int_InitialCoord,
- Int_SecondCoord,
- FixP_Velocity,
- fActive
- )
-{
- // empty
-}
-
-AcyclicPulsingCoordinate :: ~AcyclicPulsingCoordinate()
-{
- // empty
-}
-
-
-ACTIVITY_RETURN_TYPE AcyclicPulsingCoordinate :: Activity(ACTIVITY_INPUT)
-{
- #if 0
- textprint("AcyclicPulsingCoordinate :: Activity(%i)\n", FixP_Time);
- #endif
-
- int Int_CurrentCoord_Old = Int_CurrentCoord_Val;
-
- ApplyVelocity( FixP_Time );
-
- int FixP_Displacement = (FixP_Target1_Val - FixP_Position_Val);
-
- #if 0
- textprint
- (
- "FixP_Velocity_Val = %i FixP_Displacement = %i\n",
- FixP_Velocity_Val,
- FixP_Displacement
- );
- #endif
-
- if
- (
- DAVEMCRO_NONZERO_AND_OPPOSITESIGN
- (
- FixP_Velocity_Val,
- FixP_Displacement
- )
- )
- {
- {
- SetCoord_FixP
- (
- FixP_Target0_Val
- +
- FixP_Displacement
- );
- }
- }
-
- ACTIVITY_RVAL_BOOL(Int_CurrentCoord_Old != Int_CurrentCoord_Val)
-}
-
-// Pulsing coordinates: acyclic ///////////////////////////////////////////////////
-CyclicPulsingCoordinate :: CyclicPulsingCoordinate
-(
- int Int_InitialCoord,
- int Int_SecondCoord,
- int FixP_Velocity,
- OurBool fActive
-) : PulsingCoordinate
- (
- Int_InitialCoord,
- Int_SecondCoord,
- FixP_Velocity,
- fActive
- )
-{
- fGoingForSecondCoord = Yes;
-}
-
-CyclicPulsingCoordinate :: ~CyclicPulsingCoordinate()
-{
- // empty
-}
-
-ACTIVITY_RETURN_TYPE CyclicPulsingCoordinate :: Activity(ACTIVITY_INPUT)
-{
- #if 0
- textprint("CyclicPulsingCoordinate :: Activity(%i)\n", FixP_Time);
- #endif
-
- int Int_CurrentCoord_Old = Int_CurrentCoord_Val;
-
- ApplyVelocity( FixP_Time );
-
- int FixP_Displacement =
- (
- ( fGoingForSecondCoord ? FixP_Target1_Val : FixP_Target0_Val ) - FixP_Position_Val
- );
-
- #if 0
- textprint
- (
- "FixP_Velocity_Val = %i FixP_Displacement = %i\n",
- FixP_Velocity_Val,
- FixP_Displacement
- );
- #endif
-
- if
- (
- DAVEMCRO_NONZERO_AND_OPPOSITESIGN
- (
- FixP_Velocity_Val,
- FixP_Displacement
- )
- )
- {
- {
- SetCoord_FixP
- (
- ( fGoingForSecondCoord ? FixP_Target1_Val : FixP_Target0_Val )
- +
- FixP_Displacement
- );
-
- fGoingForSecondCoord = !fGoingForSecondCoord;
-
- SetVelocity_FixP
- (
- -FixP_Velocity_Val
- );
- }
- }
-
- ACTIVITY_RVAL_BOOL(Int_CurrentCoord_Old != Int_CurrentCoord_Val)
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#if 1
-HomingCoordinate::HomingCoordinate
-(
- int Int_InitialCoord,
- int Int_TargetCoord
-) : CoordinateWithVelocity
- (
- Int_InitialCoord,
- 0, //FixP_Velocity,
- (Int_InitialCoord != Int_TargetCoord)
- )
-{
- Int_TargetCoord_Val = Int_TargetCoord;
- FixP_TargetCoord_Val = OUR_INT_TO_FIXED( Int_TargetCoord );
-
- FixP_IdealVelocity_Val = DIV_FIXED
- (
- (FixP_TargetCoord_Val - FixP_Position_Val),
- FIXP_SECONDS_FOR_STANDARD_HOMING
- );
-}
-
-void HomingCoordinate :: SetCoord_Int(int Int_NewCoord)
-{
- CoordinateWithVelocity :: SetCoord_Int
- (
- Int_NewCoord
- );
-
- SetActive( Int_TargetCoord_Val != GetCoord_Int() );
-}
-
-void HomingCoordinate :: SetCoord_FixP(int FixP_NewCoord)
-{
- CoordinateWithVelocity :: SetCoord_FixP
- (
- FixP_NewCoord
- );
-
- SetActive( Int_TargetCoord_Val != GetCoord_Int() );
-}
-
-
-AcyclicHomingCoordinate :: AcyclicHomingCoordinate
-(
- int Int_InitialCoord,
- int Int_TargetCoord
-) : HomingCoordinate
- (
- Int_InitialCoord,
- Int_TargetCoord
- )
-{
- // empty
-}
-
-ACTIVITY_RETURN_TYPE AcyclicHomingCoordinate :: Activity(ACTIVITY_INPUT)
-{
- int Int_CurrentCoord_Old = Int_CurrentCoord_Val;
-
- #if 0
- textprint("acyclic homing coord for time %i\n",FixP_Time);
- #endif
-
- int FixP_Delta_Homing = (FixP_TargetCoord_Val - FixP_Position_Val);
-
- #if 0
- textprint
- (
- "current = %6i fixp = %6i\n",
- (int)Int_CurrentCoord_Val,
- (int)FixP_Position_Val
- );
-
- textprint
- (
- "target = %6i fixp = %6i\n",
- (int)Int_TargetCoord_Val,
- (int)FixP_TargetCoord_Val
- );
- #endif
-
- SetVelocity_FixP( FixP_IdealVelocity_Val );
- int FixP_Delta_Position = MUL_FIXED(FixP_Time, FixP_Velocity_Val);
-
- #if 0
- textprint
- (
- "FixP delta Homing= %6i PosN=%6i\n",
- (int)FixP_Delta_Homing,
- (int)FixP_Delta_Position
- );
- #endif
-
-
- //if target is within this frame's velocity...
- if
- (
- abs(FixP_Delta_Homing)
- <=
- abs(FixP_Delta_Position)
- )
- {
- #if 0
- textprint("within range\n");
- #endif
-
-#if 1
- SetCoord_Int
- (
- Int_TargetCoord_Val
- );
- SetVelocity_FixP( 0 );
- Stop();
-#else
- ApplyVelocity(FixP_Time);
-#endif
- }
- else
- {
- #if 0
- textprint("not within range\n");
- #endif
-
- ApplyVelocity(FixP_Time);
-
-
- }
-
- ACTIVITY_RVAL_BOOL(Int_CurrentCoord_Old != Int_CurrentCoord_Val)
-
-}
-
-
-
-
-#if 0
-OurBool AcyclicHomingCoordinate::Activity(int FixP_Time)
-{
- #if 1
- textprint("acyclic homing coord for time %i\n",FixP_Time);
- #endif
-}
-#endif
-
-
-void AcyclicHomingCoordinate :: SetTarget_Int
-(
- int Int_TargetCoord
-)
-{
- #if 0
- {
- char temp[100];
- sprintf
- (
- temp,
- "SetTarget(Int_=%i)",
- Int_TargetCoord
- );
- DAVELOG(temp);
- }
- #endif
- #if 0
- {
- textprint
- (
- "SetTarget(Int_=%i)\n",
- Int_TargetCoord
- );
- }
- #endif
-
- Int_TargetCoord_Val = Int_TargetCoord;
- FixP_TargetCoord_Val = OUR_INT_TO_FIXED( Int_TargetCoord );
-
- FixP_IdealVelocity_Val = DIV_FIXED(
- (FixP_TargetCoord_Val - FixP_Position_Val),
- FIXP_SECONDS_FOR_STANDARD_HOMING
- );
-
-
- SetActive( Int_TargetCoord != GetCoord_Int() );
-}
-
-#if 0
-OurBool AcyclicHomingCoordinate :: fTargetWithinThisFramesRange(void)
-{
-
-}
-
-void AcyclicHomingCoordinate :: ChangeVelocityBasedOnHoming(int FixP_Time)
-{
-}
-#endif
-
-// class AcyclicFixedSpeedHoming : public CoordinateWithVelocity
-// public:
-AcyclicFixedSpeedHoming :: AcyclicFixedSpeedHoming
-(
- int Int_InitialCoord,
- int Int_TargetCoord,
- int FixP_Speed_New
- // must be >= zero
-) : CoordinateWithVelocity
- (
- Int_InitialCoord, // int Int_InitialCoord,
- (
- (Int_TargetCoord > Int_InitialCoord )
- ?
- ( FixP_Speed_New )
- :
- ( -FixP_Speed_New )
- ), // int FixP_Velocity,
- ( Int_InitialCoord != Int_TargetCoord ) // OurBool fActive
- )
-{
- GLOBALASSERT( FixP_Speed_New >= 0);
-
- FixP_Speed_Val = FixP_Speed_New;
-}
-
-AcyclicFixedSpeedHoming :: ~AcyclicFixedSpeedHoming()
-{
-}
-
-ACTIVITY_RETURN_TYPE AcyclicFixedSpeedHoming :: Activity(ACTIVITY_INPUT)
-{
- int Int_CurrentCoord_Old = Int_CurrentCoord_Val;
-
- #if 0
- textprint("acyclic homing coord for time %i\n",FixP_Time);
- #endif
-
- int FixP_Delta_Homing = (FixP_TargetCoord_Val - FixP_Position_Val);
-
- #if 0
- textprint
- (
- "current = %6i fixp = %6i\n",
- (int)Int_CurrentCoord_Val,
- (int)FixP_Position_Val
- );
-
- textprint
- (
- "target = %6i fixp = %6i\n",
- (int)Int_TargetCoord_Val,
- (int)FixP_TargetCoord_Val
- );
- #endif
-
- #if 0
- SetVelocity_FixP( FixP_IdealVelocity_Val );
- #endif
-
- int FixP_Delta_Position = MUL_FIXED(FixP_Time, FixP_Velocity_Val);
-
- #if 0
- textprint
- (
- "FixP delta Homing= %6i PosN=%6i\n",
- (int)FixP_Delta_Homing,
- (int)FixP_Delta_Position
- );
- #endif
-
-
- //if target is within this frame's velocity...
- if
- (
- abs(FixP_Delta_Homing)
- <=
- abs(FixP_Delta_Position)
- )
- {
- #if 0
- textprint("within range\n");
- #endif
-
- SetCoord_FixP
- (
- FixP_TargetCoord_Val
- );
- SetVelocity_FixP( 0 );
- Stop();
- }
- else
- {
- #if 0
- textprint("not within range\n");
- #endif
-
- ApplyVelocity(FixP_Time);
-
-
- }
-
- ACTIVITY_RVAL_BOOL(Int_CurrentCoord_Old != Int_CurrentCoord_Val)
-}
-
-void AcyclicFixedSpeedHoming :: SetTarget_Int
-(
- int Int_TargetCoord
-)
-{
- Int_TargetCoord_Val = Int_TargetCoord;
- FixP_TargetCoord_Val = OUR_INT_TO_FIXED( Int_TargetCoord );
-
- #if 1
- SetVelocity_FixP
- (
- (Int_TargetCoord_Val > GetCoord_Int() )
- ?
- ( FixP_Speed_Val )
- :
- ( -FixP_Speed_Val )
- );
- #else
- if (FixP_TargetCoord_Val > FixP_Position_Val)
- {
- FixP_IdealVelocity_Val = FixP_IdealSpeed;
- }
- else
- {
- FixP_IdealVelocity_Val = -FixP_IdealSpeed;
- }
- #endif
-
- SetActive( Int_TargetCoord != GetCoord_Int() );
-}
-
-void AcyclicFixedSpeedHoming :: SetTarget_FixP
-(
- int FixP_TargetCoord
-)
-{
- Int_TargetCoord_Val = OUR_FIXED_TO_INT( FixP_TargetCoord );
- FixP_TargetCoord_Val = FixP_TargetCoord;
-
- #if 1
- SetVelocity_FixP
- (
- ( FixP_TargetCoord_Val > FixP_Position_Val )
- ?
- ( FixP_Speed_Val )
- :
- ( -FixP_Speed_Val )
- );
- #else
- if (FixP_TargetCoord_Val > FixP_Position_Val)
- {
- FixP_IdealVelocity_Val = FixP_IdealSpeed;
- }
- else
- {
- FixP_IdealVelocity_Val = -FixP_IdealSpeed;
- }
- #endif
-
- SetActive( FixP_TargetCoord != GetCoord_FixP() );
-}
-
-
-void AcyclicFixedSpeedHoming :: SetSpeed_FixP
-(
- int FixP_Speed_New
- // must be >= zero
-)
-{
- GLOBALASSERT( FixP_Speed_New >= 0);
-
- FixP_Speed_Val = FixP_Speed_New;
-
- SetVelocity_FixP
- (
- ( FixP_TargetCoord_Val > FixP_Position_Val )
- ?
- ( FixP_Speed_Val )
- :
- ( -FixP_Speed_Val )
- );
-
-}
-
-#endif
-
-
-
-
-
diff --git a/3dc/avp/support/COORDSTR.HPP b/3dc/avp/support/COORDSTR.HPP
deleted file mode 100644
index 2fe8b96..0000000
--- a/3dc/avp/support/COORDSTR.HPP
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
-
- coordstr.hpp
-
-*/
-
-#ifndef coordstr
-#define coordstr 1
-
- #ifndef _daemon
- #include "daemon.h"
- #endif
-
-/* Type definitions *****************************************************/
-
- class CoordinateWithStrategy : public Daemon
- {
- public:
- CoordinateWithStrategy
- (
- int Int_InitialCoord,
- OurBool fActive
- );
-
- virtual ~CoordinateWithStrategy();
-
- int GetCoord_Int(void);
- virtual void SetCoord_Int(int Int_NewCoord);
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT) = 0;
- // the strategy to run when active...
-
- #if 0
- virtual void UpdateScreenObject
- (
- ScreenObject* pScrObj
- ) = 0;
- #endif
-
- protected:
- int Int_CurrentCoord_Val;
- };
-
-#if 0
- class CoordinateWith2DStrategy : public Daemon
- {
- public
- CoordinateWith2DStrategy
- };
-#endif
-
- class CoordinateWithVelocity : public CoordinateWithStrategy
- {
- protected:
- void ApplyVelocity(int FixP_Time);
- int FixP_Velocity_Val;
- int FixP_Position_Val;
-
- public:
- CoordinateWithVelocity
- (
- int Int_InitialCoord,
- int FixP_Velocity,
- OurBool fActive
- );
-
- virtual ~CoordinateWithVelocity();
-
- virtual void SetCoord_Int(int Int_NewCoord);
- virtual void SetCoord_FixP(int FixP_NewCoord);
-
- void SetVelocity_FixP(int FixP_NewVelocity);
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT) = 0;
-
- int GetCoord_FixP(void) {return FixP_Position_Val;}
- int GetCoord_Int_RoundedUp(void);
-
- };
-
- class PulsingCoordinate : public CoordinateWithVelocity
- {
- public:
- PulsingCoordinate
- (
- int Int_InitialCoord,
- int Int_SecondCoord,
- int FixP_Velocity,
- OurBool fActive
- );
-
- virtual ~PulsingCoordinate();
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT) = 0;
-
- protected:
- int Int_Target0_Val;
- int FixP_Target0_Val;
-
- int Int_Target1_Val;
- int FixP_Target1_Val;
- };
-
- class AcyclicPulsingCoordinate : public PulsingCoordinate
- {
- public:
- AcyclicPulsingCoordinate
- (
- int Int_InitialCoord,
- int Int_SecondCoord,
- int FixP_Velocity,
- OurBool fActive
- );
-
- virtual ~AcyclicPulsingCoordinate();
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT);
- // base class activity; derived classes should call this
- };
-
- class CyclicPulsingCoordinate : public PulsingCoordinate
- {
- public:
- CyclicPulsingCoordinate
- (
- int Int_InitialCoord,
- int Int_SecondCoord,
- int FixP_Velocity,
- OurBool fActive
- );
-
- virtual ~CyclicPulsingCoordinate();
-
- ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT);
- private:
- OurBool fGoingForSecondCoord;
-
- };
-
-#if 1
- class HomingCoordinate : public CoordinateWithVelocity
- {
- protected:
- int Int_TargetCoord_Val;
- int FixP_TargetCoord_Val;
-
- int FixP_IdealVelocity_Val;
-
- public:
- HomingCoordinate
- (
- int Int_InitialCoord,
- int Int_TargetCoord
- );
-
- int GetTarget_Int(void) const;
-
- void SetCoord_Int(int Int_NewCoord);
- void SetCoord_FixP(int FixP_NewCoord);
-
- #if 0
- virtual OurBool fTargetWithinThisFramesRange(void) = 0;
- virtual void ChangeVelocityBasedOnHoming(int FixP_Time) = 0;
- #endif
- };
-
- // Inline fns:
- inline int HomingCoordinate::GetTarget_Int(void) const {return Int_TargetCoord_Val;}
-
-
-
- class AcyclicHomingCoordinate : public HomingCoordinate
- {
- public:
- AcyclicHomingCoordinate
- (
- int Int_InitialCoord,
- int Int_TargetCoord
- );
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT);
-
- void SetTarget_Int
- (
- int Int_TargetCoord
- );
-
- #if 0
- OurBool fTargetWithinThisFramesRange(void);
- void ChangeVelocityBasedOnHoming(int FixP_Time);
- #endif
-
- };
-
- class CyclicHomingCoordinate : public CoordinateWithStrategy
- {
- public:
- CyclicHomingCoordinate
- (
- int Int_InitialCoord,
- int Int_TargetCoord,
- int Int_MinVal,
- int Int_MaxVal
- );
-
- void SetTarget_Int
- (
- int Int_TargetCoord
- );
-
- private:
- int Int_TargetCoord_Val;
- };
-
- class AcyclicFixedSpeedHoming : public CoordinateWithVelocity
- {
- public:
- AcyclicFixedSpeedHoming
- (
- int Int_InitialCoord,
- int Int_TargetCoord,
- int FixP_Speed
- // must be >= zero
- );
- ~AcyclicFixedSpeedHoming();
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT);
-
- int GetTarget_Int(void) const;
-
- void SetTarget_Int
- (
- int Int_TargetCoord
- );
- void SetTarget_FixP
- (
- int FixP_TargetCoord
- );
-
- void SetSpeed_FixP
- (
- int FixP_Speed
- // must be >= zero
- );
-
- protected:
- int Int_TargetCoord_Val;
- int FixP_TargetCoord_Val;
-
- int FixP_Speed_Val;
-
- };
- inline int AcyclicFixedSpeedHoming::GetTarget_Int(void) const {return Int_TargetCoord_Val;}
-
-#endif
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-/* End of the header ****************************************************/
-
-#endif
diff --git a/3dc/avp/support/DAEMON.CPP b/3dc/avp/support/DAEMON.CPP
deleted file mode 100644
index 3cf38ec..0000000
--- a/3dc/avp/support/DAEMON.CPP
+++ /dev/null
@@ -1,418 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: Daemon code - things that need to be updated on a
- * per-frame basis provided they are "active"
- * AUTHOR: David Malcolm
- *
- * HISTORY:
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "daemon.h"
-
-#include "inline.h"
-
-#if SupportCallbackHooks
-#include "scrobj.hpp"
-#endif
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Constants *******************************************************/
- #define UseRealFrameTime Yes
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-/* Internal function prototypes ************************************/
-
-/* Exported globals ************************************************/
- /*static*/ int Daemon :: DaemonTimeScale = ONE_FIXED;
-
- #if !IndividualTiming
- /*static*/ int Daemon :: FixP_Time = 0;
- #endif
-
-/* Internal globals ************************************************/
-// static
-Daemon* Daemon :: p666_FirstActive = NULL;
-// static
-Daemon* Daemon :: p666_Iteration_Current = NULL;
-// static
-Daemon* Daemon :: p666_Iteration_Next = NULL;
-
-/* Exported function definitions ***********************************/
-#if SupportCallbackHooks
-// class CallbackHook
-CallbackHook :: CallbackHook
-(
- Daemon* p666_New,
- void* pUser_New
-)
-{
- if ( p666_New -> pFirstHook )
- {
- GLOBALASSERT( p666_New -> pFirstHook -> pPrvHook == NULL);
- p666_New -> pFirstHook -> pPrvHook = this;
- }
-
- pNxtHook = p666_New -> pFirstHook;
-
- p666_New -> pFirstHook = this;
-
- pPrvHook = NULL;
-
- p666_Val = p666_New;
- pUser_Val = pUser_New;
-}
-
-CallbackHook :: ~CallbackHook()
-{
- // Remove from list:
- if ( pPrvHook )
- {
- #if debug
- if ( p666_Val )
- {
- GLOBALASSERT( this != p666_Val -> pFirstHook );
- }
- #endif
- pPrvHook -> pNxtHook = pNxtHook;
- }
- else
- {
- if ( p666_Val )
- {
- // this was it's daemon's first callback:
- GLOBALASSERT( this == p666_Val -> pFirstHook );
- p666_Val -> pFirstHook = pNxtHook;
- }
- }
-
- if ( pNxtHook )
- {
- pNxtHook -> pPrvHook = pPrvHook;
- }
-
-}
-#endif // SupportCallbackHooks
-
-// class Daemon
-Daemon :: Daemon
-(
- OurBool fActive
-)
-{
- #if SupportCallbackHooks
- pFirstHook= NULL;
- #endif
-
- fIsActive_Val = No;
-
- if (fActive)
- {
- Start();
- }
- else
- {
- p666_NextActive = NULL;
- p666_PrevActive = NULL;
- }
-}
-
-Daemon :: ~Daemon()
-{
- if (fIsActive_Val)
- {
- Stop();
- }
-
- if ( p666_Iteration_Current == this )
- {
- // Then this daemon is being processed for Activity();
- // Set the static iteration ptr to NULL to signify it has been deleted
- // so that callback hooks don't get called
- p666_Iteration_Current = NULL;
- }
-
- #if SupportCallbackHooks
- // remove from screen objects lists of attached daemons
- while ( pFirstHook )
- {
- pFirstHook -> p666_Val = NULL;
-
- pFirstHook = pFirstHook -> pNxtHook;
- }
- #endif
-}
-
-
-void Daemon :: Start(void)
-{
- if (!fIsActive_Val)
- {
- // Insert at front of active 666 list
- p666_PrevActive = NULL;
- p666_NextActive = p666_FirstActive;
-
- if (p666_FirstActive)
- {
- p666_FirstActive -> p666_PrevActive = this;
- }
-
- p666_FirstActive = this;
-
- fIsActive_Val = Yes;
- }
-}
-
-void Daemon :: Stop(void)
-{
- if (fIsActive_Val)
- {
- // Remove from active 666 list
- {
- // Check against the iteration in the Maintain() static function:
- {
- if ( p666_Iteration_Next == this )
- {
- // then this is due the next daemon to have its Activity() called;
- // advance the static iteration ptr to this daemon's next
- p666_Iteration_Next = p666_NextActive;
- }
- }
-
- if ( p666_PrevActive )
- {
- GLOBALASSERT( p666_PrevActive -> fIsActive_Val );
-
- p666_PrevActive -> p666_NextActive = p666_NextActive;
- }
-
- if ( p666_NextActive )
- {
- GLOBALASSERT( p666_NextActive -> fIsActive_Val );
-
- p666_NextActive -> p666_PrevActive = p666_PrevActive;
- }
-
- if (p666_FirstActive == this)
- {
- p666_FirstActive = p666_NextActive;
- }
- }
-
- fIsActive_Val = No;
- }
-}
-
-void Daemon :: SetActive(OurBool fActive)
-{
- if (fActive)
- {
- Start();
- }
- else
- {
- Stop();
- }
-}
-
-OurBool Daemon :: bActive(void) const
-{
- return fIsActive_Val;
-}
-
-#if SupportCallbackHooks
-void Daemon :: ForceHookActivity(void)
-{
- // a way to call the OnActivity() method for all attached hooks
-
- CallbackHook* pCallbackHook = pFirstHook;
- while ( pCallbackHook )
- {
- CallbackHook* pCallbackHook_Nxt = pCallbackHook -> pNxtHook;
-
- pCallbackHook -> OnActivity();
-
- pCallbackHook = pCallbackHook_Nxt;
- }
-
-}
-#endif // SupportCallbackHooks
-
-#if 0
-void Daemon :: LinkScreenObject
-(
- ScreenObject& ScrObj
-)
-{
- UNWRITTEN();
-}
-
-void Daemon :: UnlinkScreenObject
-(
- ScreenObject& ScrObj
-)
-{
- UNWRITTEN();
-}
-#endif
-
-// static
-void Daemon :: Maintain(int FixP_Time_ToUse)
-{
- GLOBALASSERT( NULL == p666_Iteration_Current );
- GLOBALASSERT( NULL == p666_Iteration_Next );
-
- #if DaemonDiagnostics
- ProfileStart();
- #endif
-
- p666_Iteration_Current = p666_FirstActive;
-
- FixP_Time = FixP_Time_ToUse;
-
- while ( p666_Iteration_Current )
- {
- p666_Iteration_Next = p666_Iteration_Current -> p666_NextActive;
-
- {
- #if DaemonNaming && DaemonDiagnostics
- char* tempDebugName = p666_Iteration_Current -> GetDebugName();
- // in case it gets deleted during the loop
-
- ProfileStart();
- #endif
-
- #if SupportCallbackHooks
- if
- (
- p666_Iteration_Current -> Activity(FixP_Time)
- )
- {
- if ( p666_Iteration_Current )
- {
- // run the OnActivity() method for all the callback hooks attached to this daemon
- CallbackHook* pCallbackHook = p666_Iteration_Current -> pFirstHook;
- while ( pCallbackHook )
- {
- CallbackHook* pCallbackHook_Nxt = pCallbackHook -> pNxtHook;
-
- pCallbackHook -> OnActivity();
-
- pCallbackHook = pCallbackHook_Nxt;
- }
- }
- // else the iterating daemon got deleted during the call to Activity()
- }
- #else
- {
- #if IndividualTiming
- {
- p666_Iteration_Current -> Activity(FixP_Time);
- }
- #else
- {
- p666_Iteration_Current -> Activity();
- }
- #endif
- }
- #endif
-
- #if DaemonNaming && DaemonDiagnostics
- ProfileStop
- (
- tempDebugName
- );
- #endif
-
- }
- /*
- Advance to the next in the iteration.
- This will be either the next ptr of the current as stored above,
- or one further along the list (since the pNext one itself might
- have got deleted during the call to Activity)
- */
- p666_Iteration_Current = p666_Iteration_Next;
- }
-
- #if DaemonDiagnostics
-
- ProfileStop("Daemon :: Maintain()");
-
- #if CountActiveDaemons
- textprint("Num active daemons:%i\n",GetNumActive());
- #endif
-
- #endif // #if DaemonDiagnostics
-
-}
-
-void DAEMON_Init(void)
-{
-}
-
-#if UseRealFrameTime
-extern "C" extern int RealFrameTime;
-#else
-extern "C" extern int NormalFrameTime;
-#endif
-
-void DAEMON_Maintain(void)
-{
- #if 0
- textprint("DAEMON_Maintain() called\n");
- #endif
-
- #if 0
- textprint("RealFrameTime=%i\n",RealFrameTime);
- #endif
-
- int DaemonFrameTime =
- (
- #if UseRealFrameTime
- RealFrameTime
- #else
- NormalFrameTime
- #endif
- );
-
- {
- if (Daemon :: DaemonTimeScale!=ONE_FIXED)
- {
- DaemonFrameTime = MUL_FIXED(DaemonFrameTime,Daemon :: DaemonTimeScale);
- }
-
- }
-
- /* cap DaemonFrameTime if frame rate is really low */
- if (DaemonFrameTime>32768) DaemonFrameTime=32768;
-
- Daemon :: Maintain
- (
- DaemonFrameTime
- );
-}
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/command.hpp b/3dc/avp/support/command.hpp
deleted file mode 100644
index 72b932a..0000000
--- a/3dc/avp/support/command.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-
- command.hpp
-
- An object for encapsulating requests; see pp233-242 of
- "Design Patterns"
-
-*/
-
-#ifndef _command
-#define _command 1
-
- #ifndef _refobj
- #include "refobj.hpp"
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- class Command : public RefCountObject
- {
- public:
- virtual OurBool Execute(void) = 0;
- // return value is "was command completed successfully?"
-
- protected:
- // Empty constructor:
- Command() : RefCountObject() {}
-
- protected:
- // Protected destructor; Release() is the only method allowed to
- // delete it...
- virtual ~Command()
- {
- // empty
- }
- };
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/consbind.cpp b/3dc/avp/support/consbind.cpp
deleted file mode 100644
index b621bac..0000000
--- a/3dc/avp/support/consbind.cpp
+++ /dev/null
@@ -1,946 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: consbind.cpp
- *
- * Ability to kind keystrokes to strings so they appear in the
- * console when you hit the key. Initial implementation went through
- * the WM_KEYDOWN hook so that we get debouncing and typematic action
- * for free; subsequently added an implementation based on the KeyboadInput[]
- * array.
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 6/4/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "consbind.hpp"
-
- #if KeyBindingUses_KEY_ID
- #include "avpitems.hpp"
- #include "iofocus.h"
- #include "scstring.hpp"
- #include "strtab.hpp"
- #endif
-
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-#include "frontend/avp_menus.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
- #if KeyBindingUses_WM_KEYDOWN
- #define MAX_VALUE_BINDABLE_KEY (VK_DIVIDE)
- #endif
-
- #if KeyBindingUses_KEY_ID
- #define MAX_VALUE_BINDABLE_KEY (MAX_NUMBER_OF_INPUT_KEYS)
- #endif
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- extern unsigned char KeyboardInput[];
- extern unsigned char DebouncedKeyboardInput[];
-
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class KeyBinding
-// public:
-
-// static
-void
-KeyBinding :: ParseBindCommand
-(
- ProjChar* pProjCh_ToParse
-)
-{
- GLOBALASSERT(pProjCh_ToParse);
-
- BindableKey theKey;
- ProjChar* pProjCh_FollowingTheKey;
-
- if
- (
- KeyBinding :: ParseBindCommand
- (
- theKey, // BindableKey& theKey_Out,
- &pProjCh_FollowingTheKey, // ProjChar** ppProjCh_Out,
- // returns where in the input string to continue processing
-
- pProjCh_ToParse // ProjChar* pProjCh_In
- )
- )
- {
- SCString* pSCString_ToBind = new SCString(pProjCh_FollowingTheKey);
-
- // Create the KeyBinding object:
- KeyBinding* pNewBinding = new KeyBinding
- (
- theKey,
- pSCString_ToBind
- );
-
- // Feedback:
- {
- SCString* pSCString_1 = new SCString("BOUND \"");
- // LOCALISEME
-
- SCString* pSCString_2 = new SCString("\" TO ");
-
- SCString* pSCString_3 = MakeStringForKey
- (
- theKey
- );
-
- SCString* pSCString_Feedback = new SCString
- (
- pSCString_1,
- pSCString_ToBind,
- pSCString_2,
- pSCString_3
- );
-
- pSCString_Feedback -> SendToScreen();
-
- pSCString_Feedback -> R_Release();
- pSCString_3 -> R_Release();
- pSCString_2 -> R_Release();
- pSCString_1 -> R_Release();
- }
-
- pSCString_ToBind -> R_Release();
- }
- else
- {
- // Can't recognise which key is to be bound to;
- // provide an error message
- // UNWRITTEN
- }
-}
-
-// static
-void
-KeyBinding :: ParseUnbindCommand
-(
- ProjChar* pProjCh_ToParse
-)
-{
- GLOBALASSERT(pProjCh_ToParse);
-
- // Iterate through leading whitespace:
- {
- while
- (
- *pProjCh_ToParse
- )
- {
- // LOCALISEME:
- if (!isspace(*pProjCh_ToParse))
- {
- break;
- }
- pProjCh_ToParse++;
- }
- }
-
- // Scan through the string, trying to find matches against strings for keys
- // We will use the longest match:
- {
- OurBool bGotMatch = No;
- unsigned int LongestMatch = 0;
- BindableKey theKey_ToUnbind;
-
- for (int i=0;i<MAX_VALUE_BINDABLE_KEY; i++)
- {
- BindableKey theKey = (BindableKey)i;
-
- SCString* pSCString_TestKey = MakeStringForKey(theKey);
-
- unsigned int LengthOfTestString = pSCString_TestKey -> GetNumChars();
-
- if (LengthOfTestString > 0)
- {
- if
- (
- 0 == _strnicmp
- (
- pSCString_TestKey -> pProjCh(),
- pProjCh_ToParse,
- LengthOfTestString
- )
- // LOCALISEME
- )
- {
- // Then we have a match; see if it's longer than
- // what's come before...
- if (LengthOfTestString>LongestMatch)
- {
- LongestMatch = LengthOfTestString;
-
- theKey_ToUnbind = theKey;
- bGotMatch = Yes;
-
- }
- }
- }
-
- pSCString_TestKey -> R_Release();
- }
-
- if (bGotMatch)
- {
- // Then we must get rid of all bindings with this as their key:
- for
- (
- LIF<KeyBinding*> oi(&List_pKeyBindings);
- !oi . done();
- )
- {
- GLOBALASSERT(oi());
- if ( oi() -> theKey == theKey_ToUnbind )
- {
- oi . delete_current();
- }
- else
- {
- oi . next();
- }
- }
- }
- }
-}
-
-#if 0
-// static
-void
-KeyBinding :: AttemptToBind
-(
- SCString* pSCString_Key, // description of key
- SCString* pSCString_ToBind // string to be bound
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pSCString_Key );
- GLOBALASSERT( pSCString_ToBind );
- }
-
- /* CODE */
- {
- BindableKey theBindableKey_ToUse;
-
- if
- (
- !bGetKeyForString
- (
- theBindableKey_ToUse, // BindableKey& theKey_Out,
- pSCString_Key -> pProjCh()
- )
- )
- {
- // Can't recognise which key is to be bound to;
- // provide an error message
- ErrorDontRecogniseKey(pSCString_Key);
-
- return;
- }
-
- // Create the KeyBinding object:
- new KeyBinding
- (
- theBindableKey_ToUse,
- pSCString_ToBind
- );
- }
-}
-
-// static
-void
-KeyBinding :: AttemptToUnbind
-(
- SCString* pSCString_Key // description of key
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pSCString_Key );
- }
-
- /* CODE */
- {
- BindableKey theBindableKey_ToUse;
-
- if
- (
- !bGetKeyForString
- (
- theBindableKey_ToUse, // BindableKey& theKey_Out,
- pSCString_Key -> pProjCh()
- )
- )
- {
- // Can't recognise which key is to be bound to;
- // provide an error message
- ErrorDontRecogniseKey(pSCString_Key);
-
- return;
- }
-
- // Find and remove any bindings to that key; note the number:
-
- // Provide feedback:
- }
-}
-#endif
-
-
-// static
-void
-KeyBinding :: UnbindAll(void)
-{
- SCString* pSCString_Feedback = new SCString("DESTROYING ALL KEY BINDINGS");
- // LOCALISEME
-
- pSCString_Feedback -> SendToScreen();
-
- pSCString_Feedback -> R_Release();
-
- while
- (
- List_pKeyBindings . size() > 0
- )
- {
- delete List_pKeyBindings . first_entry();
- // The destructor for the KeyBinding will remove
- // it from the list and hence the list will shrink.
- }
-}
-
-// static
-void
-KeyBinding :: ListAllBindings(void)
-{
- SCString* pSCString_Feedback = new SCString("LIST OF ALL KEY BINDINGS:");
- // LOCALISEME
-
- pSCString_Feedback -> SendToScreen();
-
- pSCString_Feedback -> R_Release();
-
- for
- (
- CLIF<KeyBinding*> oi(&List_pKeyBindings);
- !oi . done();
- oi . next()
- )
- {
- GLOBALASSERT(oi());
- oi() -> ListThis();
- }
-}
-
-// static
-void KeyBinding :: WriteToConfigFile(char* Filename)
-{
- // overwrites the file with a batch file that'll
- // restore current bindings
-
- GLOBALASSERT(Filename);
-
- FILE* pFile = fopen(Filename,"w");
-
- if (!pFile)
- {
- return;
- // and don't destroy the bindings, since we won't
- // restore them next time into game
- }
-
- fprintf(pFile,"#This file generated by AVP\n");
- // LOCALISEME
-
- for
- (
- LIF<KeyBinding*> oi(&List_pKeyBindings);
- !oi.done();
- oi.next()
- )
- {
- SCString* pSCString_Key = MakeStringForKey
- (
- oi() -> theKey
- );
-
- fprintf
- (
- pFile,
- "BIND %s %s\n",
- pSCString_Key -> pProjCh(),
- oi() -> pSCString_ToOutput -> pProjCh()
- );
-
- pSCString_Key->R_Release();
- }
-
- fclose(pFile);
-
- // Destroy all the current bindings so we don't get a duplicate
- // set next time the batch file fires:
- {
- while
- (
- List_pKeyBindings . size() > 0
- )
- {
- delete List_pKeyBindings . first_entry();
- // The destructor for the KeyBinding will remove
- // it from the list and hence the list will shrink.
- }
- }
-}
-
-
-#if KeyBindingUses_WM_KEYDOWN
-// static
-void
-KeyBinding :: Process_WM_KEYDOWN
-(
- WPARAM wParam
-)
-{
-
- // Iterate through the list, finding matches.
- // We must process the matching objects later, in case they are bound to things
- // which modify the list. So we built a list of pending SCString*'s.
- // (so BIND X UNBIND X won't kill the program. I hope)
-
- // The list of pending SCStrings has been made static to the class in an attempt to
- // optimise this function
-
- // Ensure it starts off empty (which it would if it was a local):
- GLOBALASSERT( 0 == PendingList . NumEntries() );
-
- for
- (
- LIF<KeyBinding*>oi(&List_pKeyBindings);
- !oi.done();
- oi.next()
- )
- {
- // Note that the BindableKey type is type-equal to WPARAM if this function
- // exists:
- if
- (
- oi() -> theKey == wParam
- )
- {
- // Add _the_string_ to the pending list (with a reference)
- // The reference is added by the RefList template, and this ensures
- // the string stays alive whatever that pesky user does:
- GLOBALASSERT( oi() -> pSCString_ToOutput );
- PendingList . AddToEnd
- (
- *( oi() -> pSCString_ToOutput )
- );
-
- if (bEcho)
- {
- oi() -> pSCString_ToOutput -> SendToScreen();
- }
- }
- }
-
- // Iterate through the pending list, destructively reading the
- // "references" from the front:
- {
- SCString* pSCString;
-
- // The assignment in this boolean expression is deliberate:
- while
- (
- NULL != (pSCString = PendingList . GetYourFirst())
- )
- {
- pSCString -> ProcessAnyCheatCodes();
- pSCString -> R_Release();
- }
- }
-
- // Ensure the pending list finishes off empty
- // (since we're pretending it's a local variable):
- GLOBALASSERT( 0 == PendingList . NumEntries() );
-
-}
-#endif
-
-#if KeyBindingUses_KEY_ID
-// static
-void
-KeyBinding :: Maintain(void)
-{
- // Only process if we're in a running-around type of mode
- // rather than typing at the console:
- if
- (
- IOFOCUS_AcceptControls()
- )
- {
- // Iterate through the list, finding matches.
- // We must process the matching objects later, in case they are bound to things
- // which modify the list. So we built a list of pending SCString*'s.
- // (so BIND X UNBIND X won't kill the program. I hope)
-
- // The list of pending SCStrings has been made static to the class in an attempt to
- // optimise this function
-
- // Ensure it starts off empty (which it would if it was a local):
- GLOBALASSERT( 0 == PendingList . NumEntries() );
-
- for
- (
- LIF<KeyBinding*>oi(&List_pKeyBindings);
- !oi.done();
- oi.next()
- )
- {
- // Note that the BindableKey type is type-equal to enum KEY_ID if this function
- // exists:
- if
- (
- DebouncedKeyboardInput[ oi() -> theKey ]
- )
- {
- // Add _the_string_ to the pending list (with a reference)
- // The reference is added by the RefList template, and this ensures
- // the string stays alive whatever that pesky user does:
- GLOBALASSERT( oi() -> pSCString_ToOutput );
- PendingList . AddToEnd
- (
- *( oi() -> pSCString_ToOutput )
- );
-
- if (bEcho)
- {
- oi() -> pSCString_ToOutput -> SendToScreen();
- }
- }
- }
-
- // Iterate through the pending list, destructively reading the
- // "references" from the front:
- {
- SCString* pSCString;
-
- // The assignment in this boolean expression is deliberate:
- while
- (
- NULL != (pSCString = PendingList . GetYourFirst())
- )
- {
- pSCString -> ProcessAnyCheatCodes();
- pSCString -> R_Release();
- }
- }
-
- // Ensure the pending list finishes off empty
- // (since we're pretending it's a local variable):
- GLOBALASSERT( 0 == PendingList . NumEntries() );
- }
-}
-#endif
-
-
-// private:
-// Private ctor/dtor; to be called only by static fns of the class:
-KeyBinding :: KeyBinding
-(
- BindableKey theKey_ToUse,
- SCString* pSCString_ToBind
-) : theKey(theKey_ToUse),
- pSCString_ToOutput(pSCString_ToBind)
-{
- GLOBALASSERT(pSCString_ToOutput);
-
- pSCString_ToOutput -> R_AddRef();
-
- List_pKeyBindings . add_entry(this);
-}
-
-KeyBinding :: ~KeyBinding()
-{
- List_pKeyBindings . delete_entry(this);
-
- pSCString_ToOutput -> R_Release();
-}
-
-#if 0
-// static
-OurBool
-KeyBinding :: bGetKeyForString
-(
- BindableKey& theKey_Out,
- const ProjChar* const pProjCh_In
-)
-{
- #if KeyBindingUses_WM_KEYDOWN
- {
- // takes an input string and tries to figure out
- // what the corresponding WPARAM would be...
- // Returns truth if it manages to get a sensible value
- // into the output area.
-
- GLOBALASSERT( pProjCh_In );
-
- #if 1
- theKey_Out = pProjCh_In[0];
- return Yes;
- // LOCALISEME
- #else
-
- return No;
- // for now
- #endif
- }
- #endif
-
- #if KeyBindingUses_KEY_ID
- {
- theKey_Out = KEY_NUMPADDEL;
- return Yes;
- // for now
- }
- #endif
-}
-#endif
-
-// static
-void
-KeyBinding :: ErrorDontRecogniseKey( SCString* pSCString_Key )
-{
- GLOBALASSERT( pSCString_Key );
-
- SCString* pSCString_1 = new SCString("UNRECOGNISED KEY: \"");
- SCString* pSCString_2 = new SCString("\"");
- // LOCALISEME
-
- SCString* pSCString_Feedback = new SCString
- (
- pSCString_1,
- pSCString_Key,
- pSCString_2
- );
-
- pSCString_Feedback -> SendToScreen();
-
- pSCString_Feedback -> R_Release();
- pSCString_2 -> R_Release();
- pSCString_1 -> R_Release();
-}
-
-void
-KeyBinding :: ListThis(void) const
-{
- // used by ListAllBindings()
- SCString* pSCString_1 = MakeStringForKey(theKey);
- SCString* pSCString_2 = new SCString(" -> \"");
- // LOCALISEME
- SCString* pSCString_3 = new SCString("\"");
-
- SCString* pSCString_Feedback = new SCString
- (
- pSCString_1,
- pSCString_2,
- pSCString_ToOutput,
- pSCString_3
- );
-
- pSCString_Feedback -> SendToScreen();
-
- pSCString_Feedback -> R_Release();
- pSCString_3 -> R_Release();
- pSCString_2 -> R_Release();
- pSCString_1 -> R_Release();
-
-}
-
-
-static int GetKeyLabel(int inPhysicalKey, TextID& outTextID)
-{
- // takes a physical method key and attempts to find a text
- // string to use for it, returning whether it does.
- // If it fails, output area is untouched
- if (inPhysicalKey>=KEY_LEFT && inPhysicalKey<=KEY_MOUSEWHEELDOWN)
- {
- outTextID = (enum TEXTSTRING_ID) (TEXTSTRING_KEYS_LEFT + (inPhysicalKey-KEY_LEFT));
- return Yes;
- }
- else return No;
-
- #if 0
- switch (inPhysicalKey)
- {
- case KEY_UP: outTextID = TEXTSTRING_KEYS_UP; return Yes;
- case KEY_DOWN: outTextID = TEXTSTRING_KEYS_DOWN; return Yes;
- case KEY_LEFT: outTextID = TEXTSTRING_KEYS_LEFT; return Yes;
- case KEY_RIGHT: outTextID = TEXTSTRING_KEYS_RIGHT; return Yes;
- case KEY_CR: outTextID = TEXTSTRING_KEYS_RETURN; return Yes;
- case KEY_TAB: outTextID = TEXTSTRING_KEYS_TAB; return Yes;
- case KEY_INS: outTextID = TEXTSTRING_KEYS_INSERT; return Yes;
- case KEY_DEL: outTextID = TEXTSTRING_KEYS_DELETE; return Yes;
- case KEY_END: outTextID = TEXTSTRING_KEYS_END; return Yes;
- case KEY_HOME: outTextID = TEXTSTRING_KEYS_HOME; return Yes;
- case KEY_PAGEUP: outTextID = TEXTSTRING_KEYS_PGUP; return Yes;
- case KEY_PAGEDOWN: outTextID = TEXTSTRING_KEYS_PGDOWN; return Yes;
- case KEY_BACKSPACE: outTextID = TEXTSTRING_KEYS_BACKSP; return Yes;
- case KEY_COMMA: outTextID = TEXTSTRING_KEYS_COMMA; return Yes;
- case KEY_FSTOP: outTextID = TEXTSTRING_KEYS_PERIOD; return Yes;
- case KEY_SPACE: outTextID = TEXTSTRING_KEYS_SPACE; return Yes;
- case KEY_LMOUSE: outTextID = TEXTSTRING_KEYS_LMOUSE; return Yes;
- case KEY_RMOUSE: outTextID = TEXTSTRING_KEYS_RMOUSE; return Yes;
- case KEY_LEFTALT: outTextID = TEXTSTRING_KEYS_LALT; return Yes;
- case KEY_RIGHTALT: outTextID = TEXTSTRING_KEYS_RALT; return Yes;
- case KEY_LEFTCTRL: outTextID = TEXTSTRING_KEYS_LCTRL; return Yes;
- case KEY_RIGHTCTRL: outTextID = TEXTSTRING_KEYS_RCTRL; return Yes;
- case KEY_LEFTSHIFT: outTextID = TEXTSTRING_KEYS_LSHIFT; return Yes;
- case KEY_RIGHTSHIFT: outTextID = TEXTSTRING_KEYS_RSHIFT; return Yes;
- case KEY_CAPS: outTextID = TEXTSTRING_KEYS_CAPS; return Yes;
- case KEY_NUMLOCK: outTextID = TEXTSTRING_KEYS_NUMLOCK; return Yes;
- case KEY_SCROLLOK: outTextID = TEXTSTRING_KEYS_SCRLOCK; return Yes;
- case KEY_NUMPAD0: outTextID = TEXTSTRING_KEYS_PAD0; return Yes;
- case KEY_NUMPAD1: outTextID = TEXTSTRING_KEYS_PAD1; return Yes;
- case KEY_NUMPAD2: outTextID = TEXTSTRING_KEYS_PAD2; return Yes;
- case KEY_NUMPAD3: outTextID = TEXTSTRING_KEYS_PAD3; return Yes;
- case KEY_NUMPAD4: outTextID = TEXTSTRING_KEYS_PAD4; return Yes;
- case KEY_NUMPAD5: outTextID = TEXTSTRING_KEYS_PAD5; return Yes;
- case KEY_NUMPAD6: outTextID = TEXTSTRING_KEYS_PAD6; return Yes;
- case KEY_NUMPAD7: outTextID = TEXTSTRING_KEYS_PAD7; return Yes;
- case KEY_NUMPAD8: outTextID = TEXTSTRING_KEYS_PAD8; return Yes;
- case KEY_NUMPAD9: outTextID = TEXTSTRING_KEYS_PAD9; return Yes;
- case KEY_NUMPADSUB: outTextID = TEXTSTRING_KEYS_PADSUB; return Yes;
- case KEY_NUMPADADD: outTextID = TEXTSTRING_KEYS_PADADD; return Yes;
- case KEY_NUMPADDEL: outTextID = TEXTSTRING_KEYS_PADDEL; return Yes;
- default: return No;
- }
- #endif
-}
-
-static SCString* GetMethodString(BindableKey inPhysicalKey)
-{
- TextID theTextID;
-
- if
- (
- GetKeyLabel
- (
- inPhysicalKey,
- theTextID // TextID& outTextID
- )
- )
- {
- return &StringTable :: GetSCString(theTextID);
- }
- else
- {
- ProjChar theProjChar[2];
-
- if (inPhysicalKey >= KEY_A && inPhysicalKey <= KEY_Z)
- {
- theProjChar[0] = ProjChar(int(inPhysicalKey) - KEY_A + 'A');
- }
- else if (inPhysicalKey >= KEY_0 && inPhysicalKey <= KEY_9)
- {
- theProjChar[0] = ProjChar(int(inPhysicalKey) - KEY_0 + '0');
- }
- else
- {
- theProjChar[0] = 0;
- }
-
- theProjChar[1] = 0;
-
- return new SCString(theProjChar);
- }
-}
-
-// static
-SCString*
-KeyBinding :: MakeStringForKey
-(
- BindableKey theKey
-)
-{
- #if KeyBindingUses_WM_KEYDOWN
- {
- ProjChar tempProjCh[2];
-
- tempProjCh[0] = (ProjChar)theKey;
- tempProjCh[1] = 0;
- // LOCALISEME
-
-
- return new SCString(&tempProjCh[0]);
- }
- #endif
-
- #if KeyBindingUses_KEY_ID
- {
- return GetMethodString(theKey);
- }
- #endif
-}
-
-// static
-OurBool KeyBinding :: ParseBindCommand
-(
- BindableKey& theKey_Out,
- ProjChar** ppProjCh_Out,
- // returns where in the input string to continue processing
-
- ProjChar* pProjCh_In
-)
-{
- // returns Yes if it understands the binding and fills out the output
-
- GLOBALASSERT( ppProjCh_Out );
- GLOBALASSERT( pProjCh_In );
-
- // Iterate through leading whitespace:
- {
- while
- (
- *pProjCh_In
- )
- {
- // LOCALISEME:
- if (!isspace(*pProjCh_In))
- {
- break;
- }
- pProjCh_In++;
- }
- }
-
- // Scan through the string, trying to find matches against strings for keys
- // We will use the longest match:
- {
- OurBool bGotMatch = No;
- unsigned int LongestMatch = 0;
-
- for (int i=0;i<MAX_VALUE_BINDABLE_KEY; i++)
- {
- BindableKey theKey = (BindableKey)i;
-
- SCString* pSCString_TestKey = MakeStringForKey(theKey);
-
- unsigned int LengthOfTestString = pSCString_TestKey -> GetNumChars();
-
- if (LengthOfTestString > 0)
- {
- if
- (
- 0 == _strnicmp
- (
- pSCString_TestKey -> pProjCh(),
- pProjCh_In,
- LengthOfTestString
- )
- // LOCALISEME
- )
- {
- // Then we have a match; see if it's longer than
- // what's come before...
- if (LengthOfTestString>LongestMatch)
- {
- LongestMatch = LengthOfTestString;
-
- theKey_Out = theKey;
- *ppProjCh_Out = pProjCh_In + LengthOfTestString;
- // Continue processing after the string
- bGotMatch = Yes;
-
- }
- }
- }
-
- pSCString_TestKey -> R_Release();
- }
-
- if (bGotMatch)
- {
- // Strip away whitespace following the key string:
- {
- while (**ppProjCh_Out)
- {
- // LOCALISEME:
- if (!isspace(**ppProjCh_Out))
- {
- break;
- }
- (*ppProjCh_Out)++;
- }
- }
- }
-
- return bGotMatch;
- }
-
-}
-
-
-
-// private:
-// Maintain a static list of all of objects of the class:
-// static
-List<KeyBinding*> KeyBinding :: List_pKeyBindings;
-
-// static
-RefList<SCString> KeyBinding :: PendingList;
-
-// public:
-// static
-int KeyBinding :: bEcho = No;
-
-void CONSBIND_WriteKeyBindingsToConfigFile(void)
-{
- #if !(PREDATOR_DEMO|MARINE_DEMO||ALIEN_DEMO||DEATHMATCH_DEMO)
- KeyBinding :: WriteToConfigFile("CONFIG.CFG");
- #endif
-}
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/consbind.hpp b/3dc/avp/support/consbind.hpp
deleted file mode 100644
index 5df00be..0000000
--- a/3dc/avp/support/consbind.hpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-
- consbind.hpp
-
- Created 6/4/98 by DHM:
-
- Ability to bind strings to a key. When the key is pressed, the string
- is passed to the console as if it had been typed.
-*/
-
-#ifndef _consbind_hpp
-#define _consbind_hpp 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
- #ifdef __cplusplus
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
-
- #ifndef _reflist_hpp
- #include "reflist.hpp"
- #endif
- #endif /* __cplusplus */
-
-/* Version settings *****************************************************/
-#ifdef __cplusplus
- #define KeyBindingUses_WM_KEYDOWN No
- // if this is set to yes, the system works off the WM_KEYDOWN
- // messages, which provide a system for getting at the keyboard
- // which is guaranteed to work for the codes in pp247-9 of
- // Petzold 4th Edition, across all locales.
- // It also:
- // - debounces for free, then gives a typematic action
- // - won't lose keystrokes, even at low framerates
- // - provides ordering between all the keystrokes
-
- #define KeyBindingUses_KEY_ID Yes
- // if this is set, the system accesses the KeyboardInput[] array
- // in IO.C Currently (7/4/98) this comes from DirectInput, via
- // DI_FUNC.CPP
- // I have been told that this has the advantage of allowing us to treat
- // mouse/joystick buttons in an analagous way. However it has
- // the following disadvantages:
- // - it will lose keystrokes at low framerates (below 60Hz at the
- // rate I type)
- // - it loses the ordering of keystrokes that come in the same frame
- // - I believe it is locale-dependent; I believe there's no guarantee
- // it will remap according to settings in the Control Panel.
- //
- // There's no debouncing at present.
-#endif /* __cplusplus */
-
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-#ifdef __cplusplus
- #if KeyBindingUses_KEY_ID
- typedef enum KEY_ID BindableKey;
- #endif
-
- #if KeyBindingUses_WM_KEYDOWN
- typedef WPARAM BindableKey;
- #endif
-
- class KeyBinding
- {
- public:
- static void ParseBindCommand
- (
- ProjChar* pProjCh_ToParse
- );
- static void ParseUnbindCommand
- (
- ProjChar* pProjCh_ToParse
- );
-
- #if 0
- static void AttemptToBind
- (
- SCString* pSCString_Key, // description of key
- SCString* pSCString_ToBind // string to be bound
- );
- static void AttemptToUnbind
- (
- SCString* pSCString_Key // description of key
- );
- #endif
- static void UnbindAll(void);
-
- static void ListAllBindings(void);
-
- static void WriteToConfigFile(char* Filename);
- // overwrites the file with a batch file that'll
- // restore current bindings
- // Also destroys all current bindings, so that
- // next time into the game you don't get a second
- // lot when the config file is processed
-
- #if KeyBindingUses_WM_KEYDOWN
- static void Process_WM_KEYDOWN
- (
- WPARAM wParam
- );
- #endif
-
- #if KeyBindingUses_KEY_ID
- static void Maintain(void);
- #endif
-
- public:
- static int bEcho;
-
- private:
- // Private ctor/dtor; to be called only by static fns of the class:
- KeyBinding
- (
- BindableKey theKey_ToUse,
- SCString* pSCString_ToBind
- );
- ~KeyBinding();
-
- #if 0
- static OurBool bGetKeyForString
- (
- BindableKey& theKey_Out,
- const ProjChar* const pProjCh_In
- );
- // takes an input string and tries to figure out
- // what the corresponding WPARAM would be...
- // Returns truth if it manages to get a sensible value
- // into the output area.
- #endif
-
-
- static void ErrorDontRecogniseKey( SCString* pSCString_Key );
-
- void ListThis(void) const;
- // used by ListAllBindings()
-
- static SCString* MakeStringForKey
- (
- BindableKey theKey
- );
-
- static OurBool ParseBindCommand
- (
- BindableKey& theKey_Out,
- ProjChar** ppProjCh_Out,
- // returns where in the input string to continue processing
-
- ProjChar* pProjCh_In
- ); // returns Yes if it understands the binding and fills out the output
-
-
- private:
- BindableKey theKey;
- SCString* pSCString_ToOutput;
-
- // Maintain a static list of all of objects of the class:
- static List<KeyBinding*> List_pKeyBindings;
-
- // A list that ought to be local to Process_WM_KEYDOWN()
- // and the Maintain() functions
- // but has been made static to the class as an optimisation:
- static RefList<SCString> PendingList;
-
-
- };
- // Should the binding be debounced/undebounced?
- // Should the string appear to be typed?
-
- // Algorithm for processing?
-
- // Perhaps should just look at Windows messages for key down,
- // like we should have been doing all along...
-#endif /* __cplusplus */
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-#ifdef __cplusplus
- extern "C" {
-#endif
- void CONSBIND_WriteKeyBindingsToConfigFile(void);
-#ifdef __cplusplus
- };
-#endif
-
-
-/* End of the header ****************************************************/
-
-
-
-#endif
diff --git a/3dc/avp/support/consbtch.cpp b/3dc/avp/support/consbtch.cpp
deleted file mode 100644
index 0f137de..0000000
--- a/3dc/avp/support/consbtch.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: consbtch.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 8/4/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-
- #include "consbtch.hpp"
- #include "reflist.hpp"
-
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
- enum
- {
- MaxBatchFileLineLength=300,
- MaxBatchFileLineSize=(MaxBatchFileLineLength+1)
- };
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class BatchFileProcessing
-// public:
-// static
-OurBool
-BatchFileProcessing :: Run(char* Filename)
-{
- // Tries to find the file, if it finds it it reads it,
- // adds the non-comment lines to the pending list, and returns Yes
- // If it can't find the file, it returns No
-
- // LOCALISEME
- // This code makes several uses of the assumption that char is type-equal
- // to ProjChar
-
- RefList<SCString> PendingList;
-
- {
- FILE* pFile = fopen(Filename,"r");
-
- if (NULL==pFile)
- {
- return No;
- }
-
-
-
- // Read the file, line by line.
- {
- // We impose a maximum length on lines that will be valid:
- char LineBuffer[MaxBatchFileLineSize];
-
- int CharsReadInLine = 0;
-
- while (1)
- {
- int Char = fgetc(pFile);
-
- if (Char==EOF)
- {
- break;
- }
- else
- {
- if
- (
- Char=='\n'
- )
- {
- // Flush the buffer into the pending queue:
- GLOBALASSERT(CharsReadInLine<=MaxBatchFileLineLength);
- LineBuffer[CharsReadInLine] = '\0';
-
- SCString* pSCString_Line = new SCString(&LineBuffer[0]);
-
- PendingList . AddToEnd
- (
- *pSCString_Line
- );
-
- pSCString_Line -> R_Release();
-
- CharsReadInLine = 0;
- }
- else
- {
- // Add to buffer; silently reject characters beyond the length limit
- if ( CharsReadInLine < MaxBatchFileLineLength )
- {
- LineBuffer[CharsReadInLine++]=toupper((char)Char);
- }
- }
- }
- }
-
- // Flush anything still in the buffer into the pending queue:
- {
- GLOBALASSERT(CharsReadInLine<=MaxBatchFileLineLength);
- LineBuffer[CharsReadInLine] = '\0';
-
- SCString* pSCString_Line = new SCString(&LineBuffer[0]);
-
- PendingList . AddToEnd
- (
- *pSCString_Line
- );
-
- pSCString_Line -> R_Release();
- }
- }
-
- fclose(pFile);
- }
-
- // Feedback:
- {
- SCString* pSCString_1 = new SCString("EXECUTING BATCH FILE ");
- // LOCALISEME
- SCString* pSCString_2 = new SCString(Filename);
- SCString* pSCString_Feedback = new SCString
- (
- pSCString_1,
- pSCString_2
- );
-
- pSCString_Feedback -> SendToScreen();
-
- pSCString_Feedback -> R_Release();
- pSCString_2 -> R_Release();
- pSCString_1 -> R_Release();
-
- }
-
- // Now process the pending queue:
- {
- // Iterate through the pending list, destructively reading the
- // "references" from the front:
- {
- SCString* pSCString;
-
- // The assignment in this boolean expression is deliberate:
- while
- (
- NULL != (pSCString = PendingList . GetYourFirst())
- )
- {
- if (pSCString->pProjCh()[0] != '#')
- {
- // lines beginning with hash are comments
- if (bEcho)
- {
- pSCString -> SendToScreen();
- }
-
- pSCString -> ProcessAnyCheatCodes();
- }
- pSCString -> R_Release();
- }
- }
-
- }
-
- return Yes;
-
-}
-
-// public:
-// static
-int BatchFileProcessing :: bEcho = No;
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/consbtch.hpp b/3dc/avp/support/consbtch.hpp
deleted file mode 100644
index 107597d..0000000
--- a/3dc/avp/support/consbtch.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-
- consbtch.hpp
-
- Console batch file support
-
-*/
-
-#ifndef _consbtch
-#define _consbtch 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- class BatchFileProcessing
- {
- public:
- static OurBool Run(char* Filename);
- // Tries to find the file, if it finds it it reads it,
- // adds the non-comment lines to the pending list, and returns Yes
- // If it can't find the file, it returns No
-
- public:
- static int bEcho;
- };
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/daemon.h b/3dc/avp/support/daemon.h
deleted file mode 100644
index 7079bbf..0000000
--- a/3dc/avp/support/daemon.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
-
- daemon.h
-
-*/
-
-#ifndef _daemon
-#define _daemon 1
-
-#ifdef __cplusplus
-
- #ifndef _ourbool
- #include "ourbool.h"
- #endif
-
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
- #define SupportCallbackHooks No
-
- #define IndividualTiming No
- /*
- Should daemons get individually passed a time to run for,
- or do they all share the same timing information?
- */
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
- #if SupportCallbackHooks
- #define ACTIVITY_RETURN_TYPE OurBool
-
- #define ACTIVITY_RVAL_CHANGE {return Yes;}
- #define ACTIVITY_RVAL_NOCHANGE {return No;}
- #define ACTIVITY_RVAL_BOOL(b) {return b;}
- #else
- #define ACTIVITY_RETURN_TYPE void
-
- #define ACTIVITY_RVAL_CHANGE {return;}
- #define ACTIVITY_RVAL_NOCHANGE {return;}
- #define ACTIVITY_RVAL_BOOL(ignore) {return;}
- #endif
-
- #if IndividualTiming
- #define ACTIVITY_INPUT int FixP_Time
- #else
- #define ACTIVITY_INPUT void
- /* note that int FixP_Time is still available to the activity
- functions, but in the form of a protected member rather than
- an actual parameter
- */
- #endif
-
-/* Type definitions *****************************************************/
- #ifdef __cplusplus
- class Daemon;
-
- #if SupportCallbackHooks
- class CallbackHook
- {
- public:
- virtual void OnActivity(void) = 0;
-
- CallbackHook
- (
- Daemon* p666_New,
- void* pUser_New
- );
- virtual ~CallbackHook();
-
- // ought to be private:
- CallbackHook* pNxtHook;
- CallbackHook* pPrvHook;
- Daemon* p666_Val;
- void* pUser_Val;
-
-
- };
- #endif // SupportCallbackHooks
-
- class Daemon
- {
- // Constructors etc:
- public:
- Daemon
- (
- OurBool fActive
- );
-
- virtual ~Daemon();
-
- // Per object stuff:
- public:
- void Start(void);
- void Stop(void);
- void SetActive(OurBool fActive);
- OurBool bActive(void) const;
-
- virtual ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT) = 0;
- // the strategy to run when active; returns Yes if linked screen objects/gadgets will
- // need updating
-
- #if SupportCallbackHooks
- void ForceHookActivity(void);
- // a way to call the OnActivity() method for all attached hooks
- #endif
-
- // Static stuff:
- public:
- static Daemon* p666_FirstActive;
- static Daemon* p666_Iteration_Current;
- static Daemon* p666_Iteration_Next;
-
- static void Maintain(int FixP_Time);
-
- static int DaemonTimeScale;
-
- // Private stuff:
- private:
- OurBool fIsActive_Val;
- Daemon* p666_NextActive; // only valid if fIsActive
- Daemon* p666_PrevActive; // only valid if fIsActive
-
-
- #if !IndividualTiming
- protected:
- // if all Daemon activity calls share one timing; this is it:
- static int FixP_Time;
- #endif
-
- #if SupportCallbackHooks
- public: // but probably ought to be private:
- CallbackHook* pFirstHook;
- #endif
- };
- #endif // ifdef __cplusplus
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
- extern void DAEMON_Init(void);
- extern void DAEMON_Maintain(void);
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/dcontext.hpp b/3dc/avp/support/dcontext.hpp
deleted file mode 100644
index 9ef1897..0000000
--- a/3dc/avp/support/dcontext.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-
- DCONTEXT.HPP
-
- Created 14/1/98 by DHM:
-
- Dump-contexts for use by debugging routines.
-
- The idea is that debug-dump routines take a reference
- to one of these, signifying how they should output;
- these are in separate headers to avoid dependencies.
-
- There are derived classes for the screen and for log files.
-
- Analagous to the class CDumpContext in Microsoft's MFC.
-
-*/
-
-#ifndef _dcontext
-#define _dcontext 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- class R_DumpContext
- {
- public:
- virtual int dputs(char const * const buf) = 0;
- virtual int dprintf(char const * format, ... ) = 0;
- virtual int vdprintf(char const * format, va_list ap ) = 0;
- };
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
-
-
diff --git a/3dc/avp/support/expvar.hpp b/3dc/avp/support/expvar.hpp
deleted file mode 100644
index a440c8d..0000000
--- a/3dc/avp/support/expvar.hpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-
- expvar.hpp
-
- Template for variable with pure virtual get/set methods
- (I believe Borland's Delphi calls them "properties")
-
- Handy for setting up e.g. selection items in the menu system
-
- I've called them ExportVariables
-
-*/
-
-#ifndef _expvar_hpp
-#define _expvar_hpp 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
-#ifdef __cplusplus
-#endif // __cplusplus
-
-/* Type definitions *****************************************************/
-template <class T> class ExportVariable
-{
-protected:
- ExportVariable()
- {
- }
-
-public:
- virtual T Get(void) const = 0;
- virtual void Set(T NewVal) = 0;
-
-};
-
-// Similar to an ExportVariable, but has boundary values defined.
-// Can only be instantiated for types with ordering
-template <class T> class BoundedExportVariable
-{
-protected:
- BoundedExportVariable
- (
- T minVal_New,
- T maxVal_New
- ) : minVal(minVal_New),
- maxVal(maxVal_New)
- {
- }
-
-private:
- // This virtual function is private; it's only accessible within this class
- // although it must be overridden by derived classes
- virtual void Implement_Set(T NewVal) = 0;
-
-public:
- virtual T Get(void) const = 0;
-
- T GetMin(void) const
- {
- return minVal;
- }
- T GetMax(void) const
- {
- return maxVal;
- }
- void Set(T NewVal)
- {
- // Check bounds, reject if outside. Otherwise call pure virtual fn
- // (which doesn't need to bother checking)
- if (NewVal<minVal) return;
- if (NewVal>maxVal) return;
- Implement_Set(NewVal);
- }
-
-
-private:
- const T minVal;
- const T maxVal;
-};
-
-// An export var with empty "get/""set" hooks:
-template <class T> class SimpleExportVariable : public ExportVariable<T>
-{
-public:
- SimpleExportVariable
- (
- T& aT
- ) : theT(aT),
- ExportVariable()
- {
- }
-
- T Get(void) const
- {
- return theT;
- }
- void Set(T NewVal)
- {
- theT = NewVal;
- }
-
-protected:
- T& theT;
-
-};
-
-// A bounded export var with empty "get/""set" hooks:
-template <class T> class SimpleBoundedExportVariable : public BoundedExportVariable<T>
-{
-public:
- SimpleBoundedExportVariable
- (
- T& aT,
- T minVal_New,
- T maxVal_New
- ) : theT(aT),
- BoundedExportVariable
- (
- minVal_New,
- maxVal_New
- )
- {
- }
-
- T Get(void) const
- {
- return theT;
- }
-
- void Implement_Set(T NewVal)
- {
- theT = NewVal;
- }
-
-private:
- T& theT;
-
-
-};
-
-/* End of the header ****************************************************/
-
-
-
-#endif
diff --git a/3dc/avp/support/indexfnt.cpp b/3dc/avp/support/indexfnt.cpp
deleted file mode 100644
index 5d686e6..0000000
--- a/3dc/avp/support/indexfnt.cpp
+++ /dev/null
@@ -1,1336 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: indexfnt.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 18/11/97
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "inline.h"
-#include "indexfnt.hpp"
-#include "tallfont.hpp"
-
-extern "C"
-{
- #include "d3d_hud.h"
-};
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
- #define Use_BLT No
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-extern void D3D_RenderHUDString(char *stringPtr,int x,int y,int colour);
-extern void D3D_RenderHUDString_Clipped(char *stringPtr,int x,int y,int colour);
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- extern unsigned char *ScreenBuffer;
- extern long BackBufferPitch;
- extern LPDIRECTDRAWSURFACE lpDDSBack;
- extern DDPIXELFORMAT DisplayPixelFormat;
- extern int CloudTable[128][128];
- extern int CloakingPhase;
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
- /*static*/ IndexedFont* IndexedFont :: pIndexedFont[ IndexedFonts_MAX_NUMBER_OF_FONTS ];
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class IndexedFont
-// public:
-/*static*/ void IndexedFont :: UnloadFont( FontIndex I_Font_ToGet )
-{
-
- // there must be a font loaded in that slot
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pIndexedFont[I_Font_ToGet ] );
- }
-
- /* CODE */
- {
- IndexedFont* pDelete = pIndexedFont[I_Font_ToGet ];
-
- pIndexedFont[ I_Font_ToGet ] = NULL;
-
- delete pDelete;
- }
-}
-
-/*virtual*/ IndexedFont :: ~IndexedFont()
-{
- // Inform the SCString code there's been a change...
- SCString :: UpdateAfterFontChange( I_Font_Val );
-
- pIndexedFont[ I_Font_Val ] = NULL;
-}
-
-
-OurBool IndexedFont :: bCanRenderFully( ProjChar* pProjCh )
-{
- // returns true iff all characters in the string are renderable by the font
-
- // Assumes one byte-per-character:
- while ( *pProjCh )
- {
- if
- (
- !bCanRender( *pProjCh )
- )
- {
- return No;
- }
-
- pProjCh++;
- }
-
- return Yes;
-}
-
-#if debug
-void IndexedFont :: Render_Clipped_Report
-(
- const struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int,// FixP_Alpha,
- const SCString& SCStr
-) const
-{
- textprint
- (
- "IndexedFont(%i)::RenderString_Clipped() at(%i,%i) clip(%i,%i,%i,%i) \"%s\"\n",
- I_Font_Val,
- R2Pos_Cursor . x,
- R2Pos_Cursor . y,
- R2Rect_Clip . x0,
- R2Rect_Clip . y0,
- R2Rect_Clip . x1,
- R2Rect_Clip . y1,
- SCStr . pProjCh()
- );
-}
-#endif
-
-
-// protected:
-// Protected constructor since abstract class
-IndexedFont :: IndexedFont
-(
- FontIndex I_Font_New
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( I_Font_New < IndexedFonts_MAX_NUMBER_OF_FONTS );
- }
-
- /* CODE */
- {
- I_Font_Val = I_Font_New;
-
- pIndexedFont[ I_Font_New ] = this;
- }
-}
-
-
-// private:
-
-#if 1
-// class IndexedFont_Proportional : public IndexedFont
-// public:
-void IndexedFont_Proportional :: RenderString_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,// FixP_Alpha,
- const SCString& SCStr
-) const
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- #if 0
- Render_Clipped_Report
- (
- R2Pos_Cursor,
- R2Rect_Clip,
- FixP_Alpha,
- SCStr
- );
- #endif
-
- ProjChar* pProjChar_I = SCStr . pProjCh();
-
- while ( *pProjChar_I )
- {
- const ProjChar ProjCh = *pProjChar_I;
-
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
-
- #if 1
- // Rewritten by DHM 18/3/98 to use the single character renderer:
- RenderChar_Clipped
- (
- R2Pos_Cursor,
- R2Rect_Clip,
- FixP_Alpha,
- ProjCh
- );
- #else
- // For the moment, only render characters that are fully on-screen:
- if
- (
- r2rect
- (
- R2Pos_Cursor,
- GetWidth(ProjCh),
- GetHeight()
- ) . bFitsIn( R2Rect_Clip )
- )
- {
- #if Use_BLT
- R2Pos_Cursor . x += 1+BLTFontOffsetToHUD
- (
- pffont_Val, // PFFONT* font,
- R2Pos_Cursor . x, // int xdest,
- R2Pos_Cursor . y, // int ydest,
- pffont_Val -> ProjCharToOffset( ProjCh ) // int offset
- );
- #else
- textprintXY
- (
- R2Pos_Cursor . x,
- R2Pos_Cursor . y,
- "%c", ProjCh
- );
- R2Pos_Cursor . x += 1+GetWidth(ProjCh);
- #endif
- // appears to return the width of the character...
- }
- else
- {
- R2Pos_Cursor . x += GetWidth( ProjCh );
- }
- #endif
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
-
- pProjChar_I++;
- }
- }
-}
-
-void IndexedFont_Proportional :: RenderString_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha, // FixP_Alpha,
- const SCString& SCStr
-) const
-{
- {
- ProjChar* pProjChar_I = SCStr . pProjCh();
-
- while ( *pProjChar_I )
- {
- const ProjChar ProjCh = *pProjChar_I;
-
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
-
- #if 1
- // Rewritten by DHM 18/3/98 to use the single character renderer:
- RenderChar_Unclipped
- (
- R2Pos_Cursor,
- FixP_Alpha,
- ProjCh
- );
- #else
- #if Use_BLT
- R2Pos_Cursor . x += 1+BLTFontOffsetToHUD
- (
- pffont_Val, // PFFONT* font,
- R2Pos_Cursor . x, // int xdest,
- R2Pos_Cursor . y, // int ydest,
- pffont_Val -> ProjCharToOffset( ProjCh ) // int offset
- );
- // appears to return the width of the character...
- #else
- textprintXY
- (
- R2Pos_Cursor . x,
- R2Pos_Cursor . y,
- "%c", ProjCh
- );
- R2Pos_Cursor . x += 1+GetWidth(ProjCh);
- #endif
- #endif
-
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
-
- pProjChar_I++;
- }
- }
-}
-
-
-r2size IndexedFont_Proportional :: CalcSize
-(
- ProjChar* pProjCh
-) const
-{
- GLOBALASSERT( pProjCh );
-
- r2size R2Size_Return
- (
- 0,
- GetHeight()
- );
-
- if (*pProjCh)
- {
- // non-empty strings have one pixel space between characters; the if/do/while
- // construction is to take one off the final result for a non-empty string
- do
- {
- R2Size_Return . w += GetWidth( *pProjCh ) + 1;
-
- pProjCh++;
- } while (*pProjCh);
-
- R2Size_Return . w --;
- }
-
- return R2Size_Return;
-}
-
-r2size IndexedFont_Proportional :: CalcSize
-(
- ProjChar* pProjCh,
- int MaxChars
-) const
-{
- GLOBALASSERT( pProjCh );
- GLOBALASSERT( MaxChars >= 0 );
-
- r2size R2Size_Return
- (
- 0,
- GetHeight()
- );
-
- if
- (
- (*pProjCh)
- &&
- (MaxChars>0)
- )
- {
- // non-empty strings have one pixel space between characters; the if/do/while
- // construction is to take one off the final result for a non-empty string
- do
- {
- R2Size_Return . w += GetWidth( *pProjCh ) + 1;
-
- pProjCh++;
- } while
- (
- (*pProjCh)
- &&
- (--MaxChars>0)
- );
-
- R2Size_Return . w --;
- }
-
- return R2Size_Return;
-}
-
-#endif
-
-// class IndexedFont_Kerned : public IndexedFont
-// public:
-void
-IndexedFont_Kerned :: RenderString_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- const SCString& SCStr
-) const
-{
- ProjChar* pProjChar_I = SCStr . pProjCh();
-
- const LPDIRECTDRAWSURFACE image_ptr = GetImagePtr();
-
- DDSURFACEDESC ddsdimage;
-
- memset(&ddsdimage, 0, sizeof(ddsdimage));
- ddsdimage.dwSize = sizeof(ddsdimage);
-
- /* lock the image */
- while (image_ptr->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);
-
- while ( *pProjChar_I )
- {
- const ProjChar ProjCh = *pProjChar_I;
-
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
-
- #if 0
- RenderChar_Clipped
- (
- R2Pos_Cursor,
- R2Rect_Clip,
- FixP_Alpha,
- ProjCh
- );
- #else
- if (ProjCh != ' ')
- {
- unsigned int theOffset=ProjCh - 32;
- int width = GetWidth(ProjCh);
-
- /*
- if
- (
- GetOffset
- (
- theOffset,
- ProjCh
- )
- )
- */
- {
- if
- (
- width>0
- )
- {
- {
- // This code adapted from DrawGraphicWithAlphaChannel();
- // it assumes you're in a 16-bit mode...
-
- // okay, now we have the surfaces, we can copy from one to the other,
- // darkening pixels as we go
- {
- long fontimagePitchInShorts = (ddsdimage.lPitch/2);
- long backbufferPitchInShorts = (BackBufferPitch/2);
-
- unsigned short* fontimageRowStartPtr =
- (
- ((unsigned short *)ddsdimage.lpSurface)
- +
- (GetHeight()*theOffset*fontimagePitchInShorts)
- );
-
- unsigned short* backbufferRowStartPtr =
- (
- ((unsigned short *)ScreenBuffer)
- +
- (R2Pos_Cursor.y*backbufferPitchInShorts)
- +
- (R2Pos_Cursor.x)
- );
- int screenY = R2Pos_Cursor.y;
-
- for (int yCount=GetHeight(); yCount>0; yCount--)
- {
- unsigned short* fontimagePtr = fontimageRowStartPtr;
- unsigned short* backbufferPtr = backbufferRowStartPtr;
-
- if (screenY >= R2Rect_Clip.y0 && screenY <= R2Rect_Clip.y1)
- for (int xCount=width; xCount>0;xCount--)
- {
- int r = CloudTable[(xCount+R2Pos_Cursor.x+CloakingPhase/64)&127][(screenY+CloakingPhase/128)&127];
- // b += CloudTable[((xCount+R2Pos_Cursor.x)/2-CloakingPhase/96)&127][((yCount+R2Pos_Cursor.y)/4+CloakingPhase/64)&127]/4;
- // b += CloudTable[((xCount+R2Pos_Cursor.x+10)/4-CloakingPhase/64)&127][((yCount+R2Pos_Cursor.y-50)/8+CloakingPhase/32)&127]/8;
- // if (b>ONE_FIXED) b = ONE_FIXED;
- r = MUL_FIXED(FixP_Alpha,r);
- if (*fontimagePtr)
- {
- unsigned int backR = (int)(*backbufferPtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int backG = (int)(*backbufferPtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int backB = (int)(*backbufferPtr) & DisplayPixelFormat.dwBBitMask;
-
- unsigned int fontR = (int)(*fontimagePtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int fontG = (int)(*fontimagePtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int fontB = (int)(*fontimagePtr) & DisplayPixelFormat.dwBBitMask;
-
- backR += MUL_FIXED(r,fontR);
- if (backR>DisplayPixelFormat.dwRBitMask) backR = DisplayPixelFormat.dwRBitMask;
- else backR &= DisplayPixelFormat.dwRBitMask;
-
- backG += MUL_FIXED(r,fontG);
- if (backG>DisplayPixelFormat.dwGBitMask) backG = DisplayPixelFormat.dwGBitMask;
- else backG &= DisplayPixelFormat.dwGBitMask;
-
- backB += MUL_FIXED(r,fontB);
- if (backB>DisplayPixelFormat.dwBBitMask) backB = DisplayPixelFormat.dwBBitMask;
- else backB &= DisplayPixelFormat.dwBBitMask;
-
- *backbufferPtr = (short)(backR|backG|backB);
- }
- fontimagePtr++;
- backbufferPtr++;
- }
- screenY++;
- fontimageRowStartPtr += fontimagePitchInShorts;
- backbufferRowStartPtr += backbufferPitchInShorts;
- }
- }
-
- }
- }
- }
- }
-
- #endif
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
-
- R2Pos_Cursor . x += 1+GetXInc
- (
- ProjCh,
- *(pProjChar_I+1)
- );
- // this takes responsibility for updating cursor pos,
- // rather than the RenderChar function
-
- pProjChar_I++;
- }
- image_ptr->Unlock((LPVOID)ddsdimage.lpSurface);
-}
-
-void
-IndexedFont_Kerned :: RenderString_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- const SCString& SCStr
-) const
-#if 1
-{
- ProjChar* pProjChar_I = SCStr . pProjCh();
-
- const LPDIRECTDRAWSURFACE image_ptr = GetImagePtr();
-
- DDSURFACEDESC ddsdimage;
-
- memset(&ddsdimage, 0, sizeof(ddsdimage));
- ddsdimage.dwSize = sizeof(ddsdimage);
-
- /* lock the image */
- while (image_ptr->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);
-
- while ( *pProjChar_I )
- {
- const ProjChar ProjCh = *pProjChar_I;
-
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
-
- #if 0
- RenderChar_Clipped
- (
- R2Pos_Cursor,
- R2Rect_Clip,
- FixP_Alpha,
- ProjCh
- );
- #else
- if (ProjCh != ' ')
- {
- unsigned int theOffset=ProjCh - 32;
- int width = GetWidth(ProjCh);
-
- /*
- if
- (
- GetOffset
- (
- theOffset,
- ProjCh
- )
- )
- */
- {
- if
- (
- width>0
- )
- {
- {
- // This code adapted from DrawGraphicWithAlphaChannel();
- // it assumes you're in a 16-bit mode...
-
- // okay, now we have the surfaces, we can copy from one to the other,
- // darkening pixels as we go
- {
- long fontimagePitchInShorts = (ddsdimage.lPitch/2);
- long backbufferPitchInShorts = (BackBufferPitch/2);
-
- unsigned short* fontimageRowStartPtr =
- (
- ((unsigned short *)ddsdimage.lpSurface)
- +
- (GetHeight()*theOffset*fontimagePitchInShorts)
- );
-
- unsigned short* backbufferRowStartPtr =
- (
- ((unsigned short *)ScreenBuffer)
- +
- (R2Pos_Cursor.y*backbufferPitchInShorts)
- +
- (R2Pos_Cursor.x)
- );
- int screenY = R2Pos_Cursor.y;
-
- for (int yCount=GetHeight(); yCount>0; yCount--)
- {
- unsigned short* fontimagePtr = fontimageRowStartPtr;
- unsigned short* backbufferPtr = backbufferRowStartPtr;
-
- int xIndex = R2Pos_Cursor.x+CloakingPhase/64;
- int yIndex = (screenY+CloakingPhase/128)&127;
-
-// if (screenY >= R2Rect_Clip.y0 && screenY <= R2Rect_Clip.y1)
- for (int xCount=width; xCount>0;xCount--)
- {
- int r = CloudTable[(xCount+xIndex)&127][yIndex];
- // b += CloudTable[((xCount+R2Pos_Cursor.x)/2-CloakingPhase/96)&127][((yCount+R2Pos_Cursor.y)/4+CloakingPhase/64)&127]/4;
- // b += CloudTable[((xCount+R2Pos_Cursor.x+10)/4-CloakingPhase/64)&127][((yCount+R2Pos_Cursor.y-50)/8+CloakingPhase/32)&127]/8;
- // if (b>ONE_FIXED) b = ONE_FIXED;
- r = MUL_FIXED(FixP_Alpha,r);
- //int r = FixP_Alpha;
- if (*fontimagePtr)
- {
- unsigned int backR = (int)(*backbufferPtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int backG = (int)(*backbufferPtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int backB = (int)(*backbufferPtr) & DisplayPixelFormat.dwBBitMask;
-
- unsigned int fontR = (int)(*fontimagePtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int fontG = (int)(*fontimagePtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int fontB = (int)(*fontimagePtr) & DisplayPixelFormat.dwBBitMask;
-
- backR += MUL_FIXED(r,fontR);
- if (backR>DisplayPixelFormat.dwRBitMask) backR = DisplayPixelFormat.dwRBitMask;
- else backR &= DisplayPixelFormat.dwRBitMask;
-
- backG += MUL_FIXED(r,fontG);
- if (backG>DisplayPixelFormat.dwGBitMask) backG = DisplayPixelFormat.dwGBitMask;
- else backG &= DisplayPixelFormat.dwGBitMask;
-
- backB += MUL_FIXED(r,fontB);
- if (backB>DisplayPixelFormat.dwBBitMask) backB = DisplayPixelFormat.dwBBitMask;
- else backB &= DisplayPixelFormat.dwBBitMask;
-
- *backbufferPtr = (short)(backR|backG|backB);
- }
- fontimagePtr++;
- backbufferPtr++;
- }
- screenY++;
- fontimageRowStartPtr += fontimagePitchInShorts;
- backbufferRowStartPtr += backbufferPitchInShorts;
- }
- }
-
- }
- }
- }
- }
-
- #endif
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
-
- R2Pos_Cursor . x += 1+GetXInc
- (
- ProjCh,
- *(pProjChar_I+1)
- );
- // this takes responsibility for updating cursor pos,
- // rather than the RenderChar function
-
- pProjChar_I++;
- }
- image_ptr->Unlock((LPVOID)ddsdimage.lpSurface);
-}
-#else
-{
- /* PRECONDITION */
- #if 0
- {
- // Check it's already been properly clipped:
- // (using direct calculation of string sizes)
- GLOBALASSERT
- (
- r2rect
- (
- R2Pos_Cursor,
- CalcSize( SCStr . pProjCh() )
- ) . bValidPhys()
- );
- }
- #endif
- /* CODE */
- {
- ProjChar* pProjChar_I = SCStr . pProjCh();
-
- while ( *pProjChar_I )
- {
- const ProjChar ProjCh = *pProjChar_I;
-
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
-#if 1
- RenderChar_Unclipped
- (
- R2Pos_Cursor,
- FixP_Alpha,
- ProjCh
- );
-#endif
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
-
- R2Pos_Cursor . x += 1+GetXInc
- (
- ProjCh,
- *(pProjChar_I+1)
- );
- // this takes responsibility for updating cursor pos,
- // rather than the RenderChar function
-
- pProjChar_I++;
- }
- }
-}
-#endif
-
-// The string CalcSize() functions are implemented at this level
-// For this class, it's not just done by adding together the sizes for
-// the characters:
-r2size
-IndexedFont_Kerned :: CalcSize
-(
- ProjChar* pProjCh
-) const
-{
- GLOBALASSERT(pProjCh);
-
- r2size R2Size_Return
- (
- 0,
- GetHeight()
- );
-
- while (*pProjCh)
- {
- R2Size_Return . w += 1+GetXInc
- (
- *(pProjCh),
- *(pProjCh+1)
- );
- // note how the final non-null character has a call to GetXInc
- // with the null character as its successor
-
- pProjCh++;
- }
-
- return R2Size_Return;
-}
-
-r2size
-IndexedFont_Kerned :: CalcSize
-(
- ProjChar* pProjCh,
- int MaxChars
-) const
-{
- GLOBALASSERT(pProjCh);
- GLOBALASSERT( MaxChars >=0 );
-
- r2size R2Size_Return
- (
- 0,
- GetHeight()
- );
-
- while
- (
- (*pProjCh)
- &&
- ((MaxChars--)>0)
- )
- {
- R2Size_Return . w += 1+GetXInc
- (
- *(pProjCh),
- *(pProjCh+1)
- );
- // note how the final non-null character has a call to GetXInc
- // with the null character as its successor
-
- pProjCh++;
- }
-
- return R2Size_Return;
-}
-
-
-void IndexedFont_Proportional_PF :: RenderChar_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int, // FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
- // For the moment, only render characters that are fully on-screen:
- if
- (
- r2rect
- (
- R2Pos_Cursor,
- GetWidth(ProjCh),
- GetHeight()
- ) . bFitsIn( R2Rect_Clip )
- )
- {
- #if Use_BLT
- R2Pos_Cursor . x += 1+BLTFontOffsetToHUD
- (
- pffont_Val, // PFFONT* font,
- R2Pos_Cursor . x, // int xdest,
- R2Pos_Cursor . y, // int ydest,
- pffont_Val -> ProjCharToOffset( ProjCh ) // int offset
- );
- // appears to return the width of the character...
- #else
- textprintXY
- (
- R2Pos_Cursor . x,
- R2Pos_Cursor . y,
- "%c", ProjCh
- );
- R2Pos_Cursor . x += 1+GetWidth(ProjCh);
- #endif
- }
- else
- {
- R2Pos_Cursor . x += GetWidth( ProjCh );
- }
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
- }
-}
-
-void IndexedFont_Proportional_PF :: RenderChar_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int, // FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- /* PRECONDITION */
- #if 1
- {
- // Check it's already been properly clipped:
- // (using direct calculation of char size)
- GLOBALASSERT
- (
- r2rect
- (
- R2Pos_Cursor,
- CalcSize( ProjCh )
- ) . bValidPhys()
- );
- }
- #endif
- /* CODE */
- {
- if
- (
- bCanRender( ProjCh )
- )
- {
- #if 0
- textprint("printable \'%c\'\n",ProjCh);
- #endif
-
- #if Use_BLT
- R2Pos_Cursor . x += 1+BLTFontOffsetToHUD
- (
- pffont_Val, // PFFONT* font,
- R2Pos_Cursor . x, // int xdest,
- R2Pos_Cursor . y, // int ydest,
- pffont_Val -> ProjCharToOffset( ProjCh ) // int offset
- );
- // appears to return the width of the character...
- #else
- textprintXY
- (
- R2Pos_Cursor . x,
- R2Pos_Cursor . y,
- "%c", ProjCh
- );
- R2Pos_Cursor . x += 1+GetWidth(ProjCh);
- #endif
- }
- else
- {
- #if 0
- textprint("unprintable \'%c\'\n",ProjCh);
- #endif
- }
- }
-}
-
-
-/*static*/ void IndexedFont_Proportional_PF :: PFLoadHook
-(
- FontIndex I_Font_New,
- PFFONT *pffont_New
-)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- new IndexedFont_Proportional_PF
- (
- I_Font_New,
- pffont_New
- );
-
- SCString :: UpdateAfterFontChange( I_Font_New );
- }
-}
-
-/*static*/ void IndexedFont_Proportional_PF :: PFUnLoadHook
-(
- FontIndex // I_Font_Old
-)
-{
- #if 0
- delete
- SCString :: UpdateAfterFontChange( I_Font_Old );
- #endif
-}
-
-// private:
-IndexedFont_Proportional_PF :: IndexedFont_Proportional_PF
-(
- FontIndex I_Font_New,
- PFFONT *pffont_New
-) : IndexedFont_Proportional
- (
- I_Font_New
- ),
- MaxWidth_Val(0)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pffont_New );
- }
-
- /* CODE */
- {
- pffont_Val = pffont_New;
-
- // Calculate MaxWidth_Val:
- int i=(pffont_New -> num_chars_in_font);
- int Offset = pffont_New -> GetOffset();
-
- while (i>0)
- {
- i--;
-
- int ThisWidth = pffont_Val -> GetWidth
- (
- (ProjChar) (i + Offset )
- );
- if ( MaxWidth_Val < ThisWidth)
- {
- MaxWidth_Val = ThisWidth;
- }
- }
-
- }
-}
-
-
-
-
-void INDEXFNT_PFLoadHook
-(
- FontIndex I_Font_New,
- PFFONT *pffont_New
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( I_Font_New < IndexedFonts_MAX_NUMBER_OF_FONTS );
- GLOBALASSERT( pffont_New );
- }
-
- /* CODE */
- {
- IndexedFont_Proportional_PF :: PFLoadHook
- (
- I_Font_New,
- pffont_New // PFFONT *pffont_New
- );
-
- }
-}
-
-
-void IndexedFont_HUD :: RenderString_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,// FixP_Alpha,
- const SCString& SCStr
-) const
-{
- /* KJL 16:16:26 16/04/98 - if you're completely off-screen, go away */
- if (R2Pos_Cursor . y<=-HUD_FONT_HEIGHT) return;
-
- {
- ProjChar* pProjChar_I = SCStr . pProjCh();
-
- if (R2Pos_Cursor . y<=0)
- {
- D3D_RenderHUDString_Clipped(pProjChar_I,R2Pos_Cursor.x,R2Pos_Cursor.y,(255<<24)+(192<<16)+(192<<8)+(192));
- }
- else
- #if 0
- {
- HUDCharDesc charDesc;
- charDesc.Y = R2Pos_Cursor . y;
-
- charDesc.Red = 192;
- charDesc.Green = 192;
- charDesc.Blue = 192;
- charDesc.Alpha= 255;
-
- while ( *pProjChar_I )
- {
- const ProjChar ProjCh = *pProjChar_I;
-
- charDesc.Character=ProjCh;
- charDesc.X = R2Pos_Cursor . x;
- D3D_DrawHUDFontCharacter(&charDesc);
-
- R2Pos_Cursor . x += 1+GetWidth(ProjCh);
- pProjChar_I++;
- }
- }
- #else
- D3D_RenderHUDString(pProjChar_I,R2Pos_Cursor.x,R2Pos_Cursor.y,(255<<24)+(192<<16)+(192<<8)+(192));
- #endif
- }
-}
-
-void IndexedFont_HUD :: RenderString_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha, // FixP_Alpha,
- const SCString& SCStr
-) const
-{
- LOCALASSERT(0);
-}
-
-
-r2size IndexedFont_HUD :: CalcSize
-(
- ProjChar* pProjCh
-) const
-{
- GLOBALASSERT( pProjCh );
-
- r2size R2Size_Return
- (
- 0,
- GetHeight()
- );
-
- if (*pProjCh)
- {
- // non-empty strings have one pixel space between characters; the if/do/while
- // construction is to take one off the final result for a non-empty string
- do
- {
- R2Size_Return . w += GetWidth( *pProjCh ) + 1;
-
- pProjCh++;
- } while (*pProjCh);
-
- R2Size_Return . w --;
- }
-
- return R2Size_Return;
-}
-#if 0
-r2size IndexedFont_HUD :: CalcSize
-(
- ProjChar* pProjCh,
- int MaxChars
-) const
-{
- GLOBALASSERT( pProjCh );
- GLOBALASSERT( MaxChars >= 0 );
-
- r2size R2Size_Return
- (
- 0,
- GetHeight()
- );
-
- if
- (
- (*pProjCh)
- &&
- (MaxChars>0)
- )
- {
- // non-empty strings have one pixel space between characters; the if/do/while
- // construction is to take one off the final result for a non-empty string
- do
- {
- R2Size_Return . w += GetWidth( *pProjCh ) + 1;
-
- pProjCh++;
- } while
- (
- (*pProjCh)
- &&
- (--MaxChars>0)
- );
-
- R2Size_Return . w --;
- }
-
- return R2Size_Return;
-}
-#endif
-void IndexedFont_HUD :: RenderChar_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int, // FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- HUDCharDesc charDesc;
- charDesc.Y = R2Pos_Cursor . y;
-
- charDesc.Red = 255;
- charDesc.Green = 255;
- charDesc.Blue = 255;
- charDesc.Alpha= 255;
-
- charDesc.Character=ProjCh;
- charDesc.X = R2Pos_Cursor . x;
- D3D_DrawHUDFontCharacter(&charDesc);
- R2Pos_Cursor . x += GetWidth(ProjCh);
-}
-
-void IndexedFont_HUD :: RenderChar_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int, // FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- /* PRECONDITION */
- {
- // Check it's already been properly clipped:
- // (using direct calculation of char size)
- GLOBALASSERT
- (
- r2rect
- (
- R2Pos_Cursor,
- CalcSize( ProjCh )
- ) . bValidPhys()
- );
- }
-
- /* CODE */
- {
- {
-
- HUDCharDesc charDesc;
- charDesc.Character=ProjCh;
- charDesc.X = R2Pos_Cursor . x;
- charDesc.Y = R2Pos_Cursor . y;
-
- charDesc.Red = FastRandom()&255;
- charDesc.Green = FastRandom()&255;
- charDesc.Blue = FastRandom()&255;
- charDesc.Alpha=255;
-
- D3D_DrawHUDFontCharacter(&charDesc);
-
- R2Pos_Cursor . x += 1+GetWidth(ProjCh);
- }
- #if 0
- else
- {
- R2Pos_Cursor . x += GetWidth( ProjCh );
- }
- #endif
- }
-}
-
-/* Internal function definitions ***********************************/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/3dc/avp/support/indexfnt.hpp b/3dc/avp/support/indexfnt.hpp
deleted file mode 100644
index 5afa66a..0000000
--- a/3dc/avp/support/indexfnt.hpp
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
-
- indexfnt.hpp
-
- Created 19/11/97 by DHM : An "indexed font" type; it is assumed that
- there is a maximum number of possible fonts that the program can have
- installed, with an enum for accessing the different fonts (as opposed
- to a system allowing arbitrary numbers of fonts to be loaded at run-time).
-
- Expects an enum "FontIndex" for the font to be defined in PROJFONT.H
-
-
- (haven't worked out what happens for colour information/selection)
-*/
-
-#ifndef _indexfnt
-#define _indexfnt 1
-
- #ifndef _projfont
- #include "projfont.h"
- #endif
-
- #ifndef _r2base
- #include "r2base.h"
- #endif
-
-#ifdef __cplusplus
-
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
-
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-#include "HUD_layout.h"
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- #ifdef __cplusplus
- class IndexedFont
- {
- public:
- static IndexedFont* GetFont( FontIndex I_Font_ToGet );
- // can return NULL if no font loaded in that slot
-
- static void UnloadFont( FontIndex I_Font_ToGet );
- // there must be a font loaded in that slot
-
- virtual ~IndexedFont();
-
- virtual void RenderString_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- const SCString& SCStr
- ) const = 0;
- // unsupported characters come out invisible, they may or may not affect
- // the spacing/size depending on implementation
- // the cursor pos is used for both input and output; the function returns
- // the next position after the string for rendering further text
-
- virtual void RenderString_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- const SCString& SCStr
- ) const = 0;
- // unsupported characters come out invisible, they may or may not affect
- // the spacing/size depending on implementation
- // the cursor pos is used for both input and output; the function returns
- // the next position after the string for rendering further text
-
- // These functions are as above but for single characters:
- virtual void RenderChar_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const = 0;
-
- virtual void RenderChar_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const = 0;
-
- virtual r2size CalcSize
- (
- ProjChar* pProjCh
- ) const = 0;
- // calculates how big the string would occupy as a single line
- // without carriage returns etc
- // unsupported characters come out invisible, they may or may not affect
- // the spacing/size depending on implementation
- // The SCString code assumes that for any strings pCh1, pCh2:
- //
- // height(pCh1) == height (pCh2) == height (pCh1+pCh2)
- // width(pCh1 + pCh2) = width(pCh1) + width(pCh2)
- //
- // where "+" on strings used to mean concatenation
-
- virtual r2size CalcSize
- (
- ProjChar* pProjCh,
- int MaxChars
- ) const = 0;
- // as above, but will only use at most MaxChars characters, ignoring
- // any that follow (used by the word wrap code)
-
- virtual r2size CalcSize
- (
- ProjChar ProjCh
- ) const = 0;
- // calc size of individual character
- // however size of (Ch0+Ch1+...ChN) doesn't need to equal
- // size(Ch0) + size(Ch1) + ... size(ChN) because the string
- // sizing/display fns are allowed to add spacing pixels
- // in their own ways
-
- virtual OurBool bCanRender( ProjChar ProjCh_In ) const = 0;
- // many fonts don't support all the characters within the ProjChar
- // character set; you can check with this
-
- virtual int GetMaxWidth(void) const = 0;
- virtual int GetWidth
- (
- ProjChar ProjCh
- ) const = 0;
- virtual int GetHeight(void) const = 0;
-
- OurBool bCanRenderFully( ProjChar* pProjCh );
- // returns true iff all characters in the string are renderable by the font
-
- #if debug
- void Render_Clipped_Report
- (
- const struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
- #endif
-
- protected:
- // Protected constructor since abstract class
- IndexedFont
- (
- FontIndex I_Font_New
- );
-
- private:
- FontIndex I_Font_Val;
-
- static IndexedFont* pIndexedFont[ IndexedFonts_MAX_NUMBER_OF_FONTS ];
-
- };
- // Inline methods:
- inline/*static*/ IndexedFont* IndexedFont::GetFont( FontIndex I_Font_ToGet )
- {
- return pIndexedFont[ I_Font_ToGet ];
- }
-
- #if 0
- class IndexedFont_FixedSpace : public IndexedFont
- {
- public:
- private:
- };
- #endif
- /*
- KJL 17:20:10 15/04/98 - May God have mercy on my soul
- fixed space HUD font
- */
- class IndexedFont_HUD : public IndexedFont
- {
- public:
- void RenderString_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
-
- void RenderString_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
-
- void RenderChar_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- void RenderChar_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- OurBool bCanRender( ProjChar ProjCh_In ) const
- {
- return Yes;
- }
-
- inline int GetMaxWidth(void) const
- {
- return HUD_FONT_WIDTH;
- }
-
- inline int GetWidth
- (
- ProjChar ProjCh
- ) const
- {
- return AAFontWidths[ProjCh];
- }
-
- inline int GetHeight(void) const
- {
- // +2 for line spacing
- return HUD_FONT_HEIGHT+2;
- }
-
- r2size CalcSize
- (
- ProjChar* pProjCh
- ) const;
- r2size CalcSize
- (
- ProjChar* pProjCh,
- int MaxChars
- ) const;
-
- r2size CalcSize
- (
- ProjChar ProjCh
- ) const;
-
-// protected:
- IndexedFont_HUD
- (
- FontIndex I_Font_New
- ) : IndexedFont
- (
- I_Font_New
- )
- {
- }
- };
- inline r2size IndexedFont_HUD::CalcSize
- (
- ProjChar ProjCh
- ) const
- {
- return r2size
- (
- GetWidth( ProjCh ),
- GetHeight()
- );
- }
- #if 1
- inline r2size IndexedFont_HUD::CalcSize
- (
- ProjChar* pProjCh,
- int MaxChars
- ) const
- {
- int width=0;
- for (int i=0; i<MaxChars && *pProjCh!=0; i++)
- {
- width+=GetWidth(*pProjCh++);
- }
- return r2size
- (
- width,
- GetHeight()
- );
- }
- #endif
- class IndexedFont_Proportional : public IndexedFont
- {
- public:
- void RenderString_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
-
- void RenderString_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
-
- // The string CalcSize() functions are implemented at this level
- // (by repeatedly calling the virtual character level CalcSize())
- r2size CalcSize
- (
- ProjChar* pProjCh
- ) const;
- r2size CalcSize
- (
- ProjChar* pProjCh,
- int MaxChars
- ) const;
-
- r2size CalcSize
- (
- ProjChar ProjCh
- ) const;
-
- #if 0
- OurBool bCanRender( ProjChar ProjCh_In ) const;
- #endif
-
- protected:
- IndexedFont_Proportional
- (
- FontIndex I_Font_New
- ) : IndexedFont
- (
- I_Font_New
- )
- {
- }
- };
-
- // Inline methods:
- inline r2size IndexedFont_Proportional::CalcSize
- (
- ProjChar ProjCh
- ) const
- {
- return r2size
- (
- GetWidth( ProjCh ),
- GetHeight()
- );
- }
-
- // Created 3/4/98 by DHM: a new type of font in which every character
- // has a width with respect to the character following it, so that
- // e.g. "A" and "W" nuzzle together, with the top of the "W" above the
- // bottom of the "A".
- class IndexedFont_Kerned : public IndexedFont
- {
- public:
- void RenderString_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
-
- void RenderString_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- const SCString& SCStr
- ) const;
- // the RenderChar functions should not modify the cursor
- // position; this is done by the RenderString functions
-
- // The string CalcSize() functions are implemented at this level
- // For this class, it's not just done by adding together the sizes for
- // the characters:
- r2size CalcSize
- (
- ProjChar* pProjCh
- ) const;
- r2size CalcSize
- (
- ProjChar* pProjCh,
- int MaxChars
- ) const;
-
- r2size CalcSize
- (
- ProjChar ProjCh
- ) const;
-
-
- // A new pure virtual function for this class:
- // Calculate the x increment after rendering a character, assuming
- // a particular character is following. (First character must be
- // non-null; must be able to survive having the second character be
- // null, in which case the full width of the first charater is to be
- // returned).
- virtual int GetXInc
- (
- ProjChar currentProjCh,
- ProjChar nextProjCh
- ) const = 0;
-
- virtual LPDIRECTDRAWSURFACE GetImagePtr(void) const = 0;
-
- protected:
- IndexedFont_Kerned
- (
- FontIndex I_Font_New
- ) : IndexedFont
- (
- I_Font_New
- )
- {
- }
- };
-
- // Inline methods:
- inline r2size IndexedFont_Kerned::CalcSize
- (
- ProjChar ProjCh
- ) const
- {
- return r2size
- (
- GetWidth( ProjCh ),
- GetHeight()
- );
- }
-
- // Interface to the old PFFONT system written by Roxby and loathed
- // by all programmers and artists who've since worked with it...
- class IndexedFont_Proportional_PF : public IndexedFont_Proportional
- {
- public:
- void RenderChar_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- void RenderChar_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- OurBool bCanRender( ProjChar ProjCh_In ) const;
-
- int GetMaxWidth(void) const;
- int GetWidth
- (
- ProjChar ProjCh
- ) const;
- int GetHeight(void) const;
-
- static void PFLoadHook
- (
- FontIndex I_Font_New,
- PFFONT *pffont_New
- );
- static void PFUnLoadHook
- (
- FontIndex I_Font_Old
- );
-
- const PFFONT& GetPFFont(void) const;
-
- private:
- IndexedFont_Proportional_PF
- (
- FontIndex I_Font_New,
- PFFONT *pffont_New
- );
-
- PFFONT *pffont_Val;
- int MaxWidth_Val;
-
- };
-
- // Inline methods:
- inline const PFFONT& IndexedFont_Proportional_PF::GetPFFont(void) const
- {
- return *pffont_Val;
- }
-
- // both inline and virtual...
- inline OurBool IndexedFont_Proportional_PF::bCanRender( ProjChar ProjCh_In ) const
- {
- return pffont_Val -> bPrintable(ProjCh_In);
- }
-
- inline int IndexedFont_Proportional_PF::GetWidth
- (
- ProjChar ProjCh
- ) const
- {
- return pffont_Val -> GetWidth( ProjCh );
- }
- inline int IndexedFont_Proportional_PF::GetHeight(void) const { return pffont_Val -> GetHeight(); }
-
- inline int IndexedFont_Proportional_PF::GetMaxWidth(void) const
- {
- return MaxWidth_Val;
- }
-
-
-
- #endif // __cplusplus
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-#ifdef __cplusplus
- extern "C" {
-#endif
- extern void INDEXFNT_PFLoadHook
- (
- FontIndex I_Font_New,
- PFFONT *pffont_New
- );
-#ifdef __cplusplus
- };
-#endif
-
-/* End of the header ****************************************************/
-
-
-
-#endif
diff --git a/3dc/avp/support/ourbool.h b/3dc/avp/support/ourbool.h
deleted file mode 100644
index a61c20d..0000000
--- a/3dc/avp/support/ourbool.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-
- ourbool.h
-
- Exists in order to define the type OurBool;
-*/
-
-#ifndef _ourbool
-#define _ourbool 1
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- typedef char OurBool;
- // marker for an explicitly boolean type (e.g. for a return value)
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/r2base.cpp b/3dc/avp/support/r2base.cpp
deleted file mode 100644
index 23da40c..0000000
--- a/3dc/avp/support/r2base.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: r2base.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 14/11/97
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "r2base.h"
-#include "inline.h"
-
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
-
- extern int D3DDriverMode;
-
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
- /*static*/ const r2pos r2pos :: Origin = r2pos(0,0);
- /*static*/ r2rect r2rect :: R2Rect_PhysicalScreen = r2rect(0,0,640,480);
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-r2pos r2pos :: FixP_Scale
-(
- int FixP_ScaleFactor
-) const
-{
- // assumes the position to be in 16:16 fixed point,
- // returns the position scaled by the fixed pt factor
-
- return r2pos
- (
- MUL_FIXED(x, FixP_ScaleFactor),
- MUL_FIXED(y, FixP_ScaleFactor)
- );
-}
-
-
-// Repository for code that ought to be in D3_FUNC.CPP
-#if 0
-void r2rect :: AlphaFill
-(
- unsigned char R,
- unsigned char G,
- unsigned char B,
- unsigned char translucency
-) const
-{
- GLOBALASSERT
- (
- bValidPhys()
- );
-
- #if 0
- float RecipW, RecipH;
-
- // Check for textures that have not loaded properly
- LOCALASSERT(TextureHandle != (D3DTEXTUREHANDLE) 0);
-
- if(ImageHeaderArray[imageNumber].ImageWidth==128)
- {
- RecipW = 1.0 /128.0;
- }
- else
- {
- float width = (float) ImageHeaderArray[imageNumber].ImageWidth;
- RecipW = (1.0 / width);
- }
- if(ImageHeaderArray[imageNumber].ImageHeight==128)
- {
- RecipH = 1.0 / 128.0;
- }
- else
- {
- float height = (float) ImageHeaderArray[imageNumber].ImageHeight;
- RecipH = (1.0 / height);
- }
- #endif
-
-
- /* OUTPUT quadVerticesPtr TO EXECUTE BUFFER */
- {
- D3DCOLOR Colour;
-
- switch (D3DDriverMode)
- {
- case D3DSoftwareRGBDriver:
- {
- Colour = RGBLIGHT_MAKE(R,G,B);
- break;
- }
-
- case D3DSoftwareRampDriver:
- {
- Colour = RGB_MAKE(0,0,B);
- break;
- }
-
- default:
- case D3DHardwareRGBDriver:
- {
- Colour = RGBALIGHT_MAKE(R,G,B,translucency);
- break;
- }
- }
-
- #if 1
- {
- D3DTLVERTEX *vertexPtr = &((LPD3DTLVERTEX)ExecuteBufferDataArea)[NumVertices];
-
- /* Vertex 0 = Top left */
- vertexPtr->sx= x0;
- vertexPtr->sy= y0;
- vertexPtr->color = Colour;
-
- NumVertices++;
- vertexPtr++;
-
- /* Vertex 1 = Top right */
- vertexPtr->sx=( x1 - 1);
- vertexPtr->sy=( y0 );
- vertexPtr->color = Colour;
-
- NumVertices++;
- vertexPtr++;
-
- /* Vertex 2 = Bottom right */
- vertexPtr->sx=( x1 - 1);
- vertexPtr->sy=( y1 - 1);
- vertexPtr->color = Colour;
-
- NumVertices++;
- vertexPtr++;
-
- /* Vertex 3 = Bottom left */
- vertexPtr->sx=x0;
- vertexPtr->sy=( y1 - 1);
- vertexPtr->color = Colour;
-
- NumVertices++;
- }
- #else
- int i = 4;
- do
- {
- D3DTLVERTEX *vertexPtr = &((LPD3DTLVERTEX)ExecuteBufferDataArea)[NumVertices];
-
-// textprint("x %d, y %d, u %d, v %d\n",quadVerticesPtr->X,quadVerticesPtr->Y,quadVerticesPtr->U,quadVerticesPtr->V);
- vertexPtr->sx=quadVerticesPtr->X;
- vertexPtr->sy=quadVerticesPtr->Y;
- #if 0
- vertexPtr->tu = ((float)(quadVerticesPtr->U)) * RecipW;
- vertexPtr->tv = ((float)(quadVerticesPtr->V)) * RecipH;
- #endif
-
- vertexPtr->color = Colour;
- }
- quadVerticesPtr++;
- NumVertices++;
- }
- while(--i);
- #endif
- }
-
- // set correct texture handle
- if (0 != CurrTextureHandle)
- {
- OP_STATE_RENDER(1, ExecBufInstPtr);
- STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, 0, ExecBufInstPtr);
- CurrTextureHandle = 0;
- }
-
- /* output triangles to execute buffer */
- OP_TRIANGLE_LIST(2, ExecBufInstPtr);
- OUTPUT_TRIANGLE(0,1,3, 4);
- OUTPUT_TRIANGLE(1,2,3, 4);
-
- /* check to see if buffer is getting full */
- if (NumVertices > (MaxD3DVertices-12))
- {
- WriteEndCodeToExecuteBuffer();
- UnlockExecuteBufferAndPrepareForUse();
- ExecuteBuffer();
- LockExecuteBuffer();
- }
-}
-#endif
-
-r2pos operator+ ( const r2pos& R2Pos_1, const r2pos& R2Pos_2 )
-{
- return r2pos
- (
- R2Pos_1 . x + R2Pos_2 . x,
- R2Pos_1 . y + R2Pos_2 . y
- );
-}
-
-
-extern void R2BASE_ScreenModeChange_Setup(void)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- }
-}
-
-extern "C" extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
-
-extern void R2BASE_ScreenModeChange_Cleanup(void)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
-
- r2rect :: R2Rect_PhysicalScreen .x1 = ScreenDescriptorBlock.SDB_Width;
- r2rect :: R2Rect_PhysicalScreen .y1 = ScreenDescriptorBlock.SDB_Height;
- }
-}
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/r2base.h b/3dc/avp/support/r2base.h
deleted file mode 100644
index 64daed9..0000000
--- a/3dc/avp/support/r2base.h
+++ /dev/null
@@ -1,638 +0,0 @@
-/*
-
- r2base.h
-
- Created 13/11/97 by David Malcolm
-
- "R2" is a proposed 2d-rendering interface; this
- is the base header for it
-
-*/
-
-#ifndef _r2base
-#define _r2base 1
-
-//#ifdef __cplusplus
- //extern "C" {
-//#endif
-
-/* Version settings *****************************************************/
- #define UseTemplates No
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- struct r2pos
- {
- int x;
- int y;
-
- #ifdef __cplusplus
- static const r2pos Origin;
- // always (0,0)
-
- // Construction
- r2pos() : x(0), y(0)
- {
- // empty
- }
- r2pos(int x_new,int y_new) : x(x_new), y(y_new)
- {
- // empty
- }
-
- #if 0
- friend bool operator==(const r2pos& R2Pos_1, const r2pos& R2Pos_2);
- #endif
-
- int bIsOrigin(void) const;
-
- friend r2pos operator+ ( const r2pos& R2Pos_1, const r2pos& R2Pos_2 );
- void operator+= ( const r2pos& R2Pos );
- // standard vector arithmetic
-
- r2pos FixP_Scale
- (
- int FixP_ScaleFactor
- ) const;
- // assumes the position to be in 16:16 fixed point,
- // returns the position scaled by the fixed pt factor
-
- int ApproxMagnitude(void) const;
- // assumes the position to be in 16:16 fixed point
-
- #endif // __cplusplus
- }; // suggested naming convention: "R2Pos"
-
- #ifdef __cplusplus
- // Inline methods:
- inline int r2pos::bIsOrigin(void) const
- {
- if (x==0)
- {
- if (y==0)
- {
- return Yes;
- }
- }
- return No;
- }
-
- inline void r2pos::operator+=
- (
- const r2pos& R2Pos
- )
- {
- x += R2Pos . x;
- y += R2Pos . y;
- }
-
- inline int r2pos::ApproxMagnitude(void) const
- {
- // assumes the position to be in 16:16 fixed point
- // based around the Foley+vanDam 2d distance function
- int xAbs = (x>0) ? x : -x;
- int yAbs = (y>0) ? y : -y;
-
- int xyMax = (xAbs > yAbs) ? xAbs : yAbs;
-
- return (xAbs + yAbs + (xyMax * 2));
- }
- #endif /* __cplusplus */
-
-
- #if UseTemplates
- #ifdef __cplusplus
- // C++ implementation:
- // r2size defined from a template
- template <class ValType> struct size2d
- {
- ValType w;
- ValType h;
-
- // Construction:
- size2d() : w(0), h(0)
- {
- // empty
- }
-
- size2d(ValType w_new,ValType h_new) : w(w_new), h(h_new)
- {
- // empty
- }
-
- // Method declarations:
- int bHasArea(void);
- // Does this size have non-zero area?:
-
- void VCompose(const size2d& Size2D_Other );
- void HCompose(const size2d& Size2D_Other );
- // update size to the size necessary for composing
- // this and another size either vertically or horizontally
-
-
- // Inline methods:
- int bHasArea(void)
- {
- // Does this size have non-zero area?:
- if (w<=0)
- {
- return No;
- }
- if (h<=0)
- {
- return No;
- }
- return Yes;
- }
- void VCompose(const size2d& Size2D_Other )
- {
- // sum of heights; greater of widths
-
- h += Size2D_Other . h;
-
- if (w < Size2D_Other . w)
- {
- w = Size2D_Other . w;
- }
- }
- void HCompose(const size2d& Size2D_Other )
- {
- // sum of widths; greater of heights
- w += Size2D_Other . w;
-
- if (h < Size2D_Other . h)
- {
- h = Size2D_Other . h;
- }
- }
-
- }; // Suggested naming convention: "Size2D"
-
- typedef size2d<int> r2size; // suggested naming convention: "R2Size"
- #else
- /* C implementation: r2size defined as a simple struct: */
-
- struct r2size
- {
- int w;
- int h;
- }; /* suggested naming convention: "R2Size" */
-
- #endif // __cplusplus
- #else // UseTemplates
- struct r2size
- {
- int w;
- int h;
-
- #ifdef __cplusplus
- // Construction:
- r2size() : w(0), h(0)
- {
- // empty
- }
-
- r2size(int w_new,int h_new) : w(w_new), h(h_new)
- {
- // empty
- }
-
- // Method declarations:
- int bHasArea(void);
- // Does this size have non-zero area?:
-
- void VCompose(const r2size& R2Size_Other );
- void HCompose(const r2size& R2Size_Other );
- // update size to the size necessary for composing
- // this and another size either vertically or horizontally
-
- #endif // __cplusplus
-
- }; // Suggested naming convention: "Size2D"
-
- #ifdef __cplusplus
- // Inline methods:
- inline int r2size::bHasArea(void)
- {
- // Does this size have non-zero area?:
- if (w<=0)
- {
- return No;
- }
- if (h<=0)
- {
- return No;
- }
- return Yes;
- }
- inline void r2size::VCompose(const r2size& R2Size_Other )
- {
- // sum of heights; greater of widths
-
- h += R2Size_Other . h;
-
- if (w < R2Size_Other . w)
- {
- w = R2Size_Other . w;
- }
- }
- inline void r2size::HCompose(const r2size& R2Size_Other )
- {
- // sum of widths; greater of heights
- w += R2Size_Other . w;
-
- if (h < R2Size_Other . h)
- {
- h = R2Size_Other . h;
- }
- }
- #endif /* __cplusplus */
-
- #endif // UseTemplates
-
- struct r2rect
- {
- int x0;
- int y0;
- int x1;
- int y1;
-
- // Rectangle defined in the "Windows" fashion
- // i.e. first coord is top-left of rectangle and inside it
- // second coord is bottom-right of rectange and immediately
- // outside it. If the second coord is co-incident with the first
- // or to the left or above, then the rectangle has zero area; no
- // points are within it
-
- #ifdef __cplusplus
- // Friends:
- friend void R2BASE_ScreenModeChange_Cleanup(void);
- // allowed to update the internal record of the dimensions of the physical screen
-
- // Construction:
- r2rect(int x0_new,int y0_new,int x1_new,int y1_new) :
- x0(x0_new),
- y0(y0_new),
- x1(x1_new),
- y1(y1_new)
- {
- // empty
- }
-
- r2rect(int x0_new,int y0_new, r2size R2Size) :
- x0(x0_new),
- y0(y0_new),
- x1(x0_new + R2Size . w),
- y1(y0_new + R2Size . h)
- {
- // empty
- }
-
- r2rect(struct r2pos R2Pos, r2size R2Size) :
- x0(R2Pos . x),
- y0(R2Pos . y),
- x1(R2Pos . x + R2Size . w),
- y1(R2Pos . y + R2Size . h)
- {
- // empty
- }
-
- r2rect(struct r2pos R2Pos, int W,int H) :
- x0(R2Pos . x),
- y0(R2Pos . y),
- x1(R2Pos . x + W),
- y1(R2Pos . y + H)
- {
- // empty
- }
-
- // Method declarations:
- int bHasArea(void) const;
- struct r2pos GetPos(void) const;
- r2size GetSize(void) const;
- int Width(void) const;
- int Height(void) const;
- void SetWidth(int w_New);
- void SetHeight(int h_New);
- int bWithin( const struct r2pos& R2Pos ) const;
- // is point inside this rect
-
- int bFitsIn( const struct r2rect& R2Rect ) const;
- // is this rect fully inside ?
-
- int bOverlap( const struct r2rect& R2Rect_ToTest ) const;
- void Clip( struct r2rect& R2Rect_ToClip ) const;
- void Clip(const struct r2rect& R2Rect_In, struct r2rect& R2Rect_Out ) const;
- static const r2rect& PhysicalScreen(void);
- // for read-only access to the dimensions of the physical screen
-
- int bValidPhys(void) const;
- // is this a valid rect within the physical screen?
- // useful for asserting in a rendering routine
-
- // Access to 9 "interesting" positions in the rectangle:
- // top-left, top-middle, etc...
- r2pos Hotspot_TL(void) const;
- r2pos Hotspot_TM(void) const;
- r2pos Hotspot_TR(void) const;
- r2pos Hotspot_ML(void) const;
- r2pos Hotspot_MM(void) const;
- r2pos Hotspot_MR(void) const;
- r2pos Hotspot_BL(void) const;
- r2pos Hotspot_BM(void) const;
- r2pos Hotspot_BR(void) const;
-
- r2pos Centre(void) const { return Hotspot_MM(); }
-
- r2pos CentredWithSize_TL( r2size R2Size_In ) const;
- // finds location for top left of a rect with the given size so that
- // it gets centred on this rect
-
- // Rendering:
- void AlphaFill
- (
- unsigned char R,
- unsigned char G,
- unsigned char B,
- unsigned char translucency
- ) const;
-
-
- private:
- static r2rect R2Rect_PhysicalScreen;
-
- #endif // __cplusplus
- }; // suggested naming convention: "R2Rect"
-
- #ifdef __cplusplus
- // Inline methods:
- inline int r2rect::bHasArea(void) const
- {
- if (x1<=x0)
- {
- return No;
- }
- if (y1<=y0)
- {
- return No;
- }
- return Yes;
- }
- inline struct r2pos r2rect::GetPos(void) const
- {
- return r2pos(x0,y0);
- }
- inline r2size r2rect::GetSize(void) const
- {
- return r2size(x1-x0,y1-y0);
- }
- inline int r2rect::Width(void) const
- {
- return x1-x0;
- }
- inline int r2rect::Height(void) const
- {
- return y1-y0;
- }
- inline void r2rect::SetWidth(int w_New)
- {
- x1 = x0 + w_New;
- }
- inline void r2rect::SetHeight(int h_New)
- {
- y1 = y0 + h_New;
- }
- inline int r2rect::bWithin( const struct r2pos& R2Pos ) const
- {
- if
- (
- R2Pos . x < x0
- )
- {
- return No;
- }
- if
- (
- R2Pos . y < y0
- )
- {
- return No;
- }
- if
- (
- R2Pos . x >= x1
- )
- {
- return No;
- }
- if
- (
- R2Pos . y >= y1
- )
- {
- return No;
- }
- return Yes;
- }
- inline int r2rect::bFitsIn( const struct r2rect& R2Rect ) const
- {
- if ( x0 < R2Rect . x0)
- {
- return No;
- }
- if ( y0 < R2Rect . y0)
- {
- return No;
- }
- if ( x1 > R2Rect . x1)
- {
- return No;
- }
- if ( y1 > R2Rect . y1)
- {
- return No;
- }
- return Yes;
- }
- inline int r2rect::bOverlap( const struct r2rect& R2Rect_ToTest ) const
- {
- if ( x0 >= R2Rect_ToTest . x1 )
- {
- return No;
- }
- if ( y0 >= R2Rect_ToTest . y1 )
- {
- return No;
- }
- if ( x1 <= R2Rect_ToTest . x0 )
- {
- return No;
- }
- if ( y1 <= R2Rect_ToTest . y0 )
- {
- return No;
- }
- return Yes;
- }
- inline void r2rect::Clip( struct r2rect& R2Rect_ToClip ) const
- {
- if ( R2Rect_ToClip . x0 < x0)
- {
- R2Rect_ToClip . x0 = x0;
- }
- if ( R2Rect_ToClip . y0 < y0)
- {
- R2Rect_ToClip . y0 = y0;
- }
- if ( R2Rect_ToClip . x1 >= x1)
- {
- R2Rect_ToClip . x1 = x1;
- }
- if ( R2Rect_ToClip . y1 >= y1)
- {
- R2Rect_ToClip . y1 = y1;
- }
- }
- #if 0
- inline void r2rect::Clip(const struct r2rect& R2Rect_In, struct r2rect& R2Rect_Out )
- {
- R2Rect_Out . x0 =
- }
- #endif
- inline /*static*/ const r2rect& r2rect::PhysicalScreen(void)
- {
- return R2Rect_PhysicalScreen;
- }
- inline int r2rect::bValidPhys(void) const
- {
- // is this a valid rect within the physical screen?
- // useful for asserting in a rendering routine
- if ( x0 < 0 )
- {
- return No;
- }
- if ( y0 < 0 )
- {
- return No;
- }
- if ( x1 > R2Rect_PhysicalScreen . x1 )
- {
- return No;
- }
- if ( y1 > R2Rect_PhysicalScreen . y1 )
- {
- return No;
- }
- // Check for well-formedness:
- if ( x0 > x1 )
- {
- return No;
- }
- if ( y0 > y1 )
- {
- return No;
- }
-
- return Yes;
- }
- inline r2pos r2rect::Hotspot_TL(void) const
- {
- return r2pos
- (
- x0,
- y0
- );
- }
- inline r2pos r2rect::Hotspot_TM(void) const
- {
- return r2pos
- (
- (x0+x1)/2,
- y0
- );
- }
- inline r2pos r2rect::Hotspot_TR(void) const
- {
- return r2pos
- (
- (x1-1),
- y0
- );
- }
- inline r2pos r2rect::Hotspot_ML(void) const
- {
- return r2pos
- (
- x0,
- (y0+y1)/2
- );
- }
- inline r2pos r2rect::Hotspot_MM(void) const
- {
- return r2pos
- (
- (x0+x1)/2,
- (y0+y1)/2
- );
- }
- inline r2pos r2rect::Hotspot_MR(void) const
- {
- return r2pos
- (
- (x1-1),
- (y0+y1)/2
- );
- }
- inline r2pos r2rect::Hotspot_BL(void) const
- {
- return r2pos
- (
- x0,
- (y1-1)
- );
- }
- inline r2pos r2rect::Hotspot_BM(void) const
- {
- return r2pos
- (
- (x0+x1)/2,
- (y1-1)
- );
- }
- inline r2pos r2rect::Hotspot_BR(void) const
- {
- return r2pos
- (
- (x1-1),
- (y1-1)
- );
- }
-
- inline r2pos r2rect::CentredWithSize_TL( r2size R2Size_In ) const
- {
- return r2pos
- (
- x0+((Width() - R2Size_In . w)/2),
- y0+((Height() - R2Size_In . h)/2)
- );
- }
- #endif /* __cplusplus */
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
- extern void R2BASE_ScreenModeChange_Setup(void);
- extern void R2BASE_ScreenModeChange_Cleanup(void);
-
-
-/* End of the header ****************************************************/
-
-
-//#ifdef __cplusplus
-// };
-//#endif
-
-#endif
diff --git a/3dc/avp/support/r2pos666.cpp b/3dc/avp/support/r2pos666.cpp
deleted file mode 100644
index 3135a8f..0000000
--- a/3dc/avp/support/r2pos666.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: r2pos666.cpp - Daemonic r2 positions
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 1/12/97
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "r2pos666.hpp"
-#include "inline.h"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class R2PosDaemon : public Daemon
-// public:
-R2PosDaemon :: R2PosDaemon
-(
- r2pos R2Pos_Int_Initial,
- OurBool bActive
-) : Daemon( bActive ),
- R2Pos_Int_Current( R2Pos_Int_Initial ),
- R2Pos_FixP_Current
- (
- OUR_INT_TO_FIXED( R2Pos_Int_Initial . x ),
- OUR_INT_TO_FIXED( R2Pos_Int_Initial . y )
- )
-{
-
-}
-
-void R2PosDaemon :: SetPos_Int(const r2pos R2Pos_Int_New )
-{
- R2Pos_Int_Current = R2Pos_Int_New;
- R2Pos_FixP_Current = r2pos
- (
- OUR_INT_TO_FIXED( R2Pos_Int_Current . x ),
- OUR_INT_TO_FIXED( R2Pos_Int_Current . y )
- );
-}
-
-void R2PosDaemon :: SetPos_FixP(const r2pos R2Pos_FixP_New )
-{
- R2Pos_FixP_Current = R2Pos_FixP_New;
- R2Pos_Int_Current = r2pos
- (
- OUR_FIXED_TO_INT( R2Pos_FixP_Current . x ),
- OUR_FIXED_TO_INT( R2Pos_FixP_Current . y )
- );
-}
-
-// Activity remains pure virtual...
-
-
-// private:
-#if 0
-r2pos R2Pos_Int_Current;
-r2pos R2Pos_FixP_Current;
-#endif
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/r2pos666.hpp b/3dc/avp/support/r2pos666.hpp
deleted file mode 100644
index a9adcdd..0000000
--- a/3dc/avp/support/r2pos666.hpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-
- r2pos666.hpp
-
-*/
-
-#ifndef _r2pos666
-#define _r2pos666 1
-
- #ifndef _r2base
- #include "r2base.h"
- #endif
-
- #ifndef _daemon
- #include "daemon.h"
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- class R2PosDaemon : public Daemon
- {
- public:
- R2PosDaemon
- (
- r2pos R2Pos_Int_Initial,
- OurBool bActive
- );
-
- ~R2PosDaemon()
- {
- // empty
- }
-
- r2pos GetPos_Int(void) const;
- r2pos GetPos_FixP(void) const;
-
- void SetPos_Int(const r2pos R2Pos_Int_New );
- void SetPos_FixP(const r2pos R2Pos_FixP_New );
-
- // Activity remains pure virtual...
-
- private:
- r2pos R2Pos_Int_Current;
- r2pos R2Pos_FixP_Current;
-
- };
- // Inline methods:
- inline r2pos R2PosDaemon::GetPos_Int(void) const
- {
- return R2Pos_Int_Current;
- }
- inline r2pos R2PosDaemon::GetPos_FixP(void) const
- {
- return R2Pos_FixP_Current;
- }
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/rebitems.cpp b/3dc/avp/support/rebitems.cpp
deleted file mode 100644
index 0027a9a..0000000
--- a/3dc/avp/support/rebitems.cpp
+++ /dev/null
@@ -1,870 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: rebitems.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 9/3/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-
- #include "rebitems.hpp"
-
- #if UseRebMenus
- #include "strtab.hpp"
- #include "indexfnt.hpp"
-
- #include "module.h"
- // to include stratdef.h
-
- #include "stratdef.h"
- // to include usr_io.h
-
- #include "usr_io.h"
-
- #include "db.h"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
- #endif
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-#if UseRebMenus
-// static
-const FontIndex RebMenus :: Fonts :: LabelFont_InGame = DATABASE_MESSAGE_FONT;
-// static
-const FontIndex RebMenus :: Fonts :: LabelFont_OutOfGame_Selected = IntroFont_Light;
-const FontIndex RebMenus :: Fonts :: LabelFont_OutOfGame_Unselected = IntroFont_Dark;
-#endif
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-#if UseRebMenus
-// Derived classes for the item types:
-//class Item_Unimplemented : public Item
-// public:
-// Process various keypresses:
-OurBool
-RebMenus :: Item_Unimplemented :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
- switch ( aNavOp )
- {
- case NavOp_Trigger:
- textprint("this is an unimplemented item\n");
- return Yes;
-
- case NavOp_Up:
- case NavOp_Down:
- case NavOp_Left:
- case NavOp_Right:
- case NavOp_Home:
- case NavOp_End:
- case NavOp_Cancel:
- // No way of processing
- return No;
-
- default:
- GLOBALASSERT(0);
- }
- return No;
-}
-
-void
-RebMenus :: Item_Unimplemented :: Diagnostic(OurBool bSelected) const
-{
- textprint("Unimplemented:");
-
- DiagnosticAppearance(bSelected);
-}
-
-// Methods relating to rendering:
-void
-RebMenus :: Item_Unimplemented :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- RenderAppearance
- (
- theContext,
- bSelected
- );
-}
-
-RebMenus :: SizeInfo
-RebMenus :: Item_Unimplemented :: GetSizeInfo(void) const
-{
- return AppearanceSizeInfo();
-}
-// public:
-// Process various keypresses:
-OurBool
-RebMenus :: Item_Command :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
- switch ( aNavOp )
- {
- case NavOp_Trigger:
- return pCommand_Val -> Execute();
-
- case NavOp_Up:
- case NavOp_Down:
- case NavOp_Left:
- case NavOp_Right:
- case NavOp_Home:
- case NavOp_End:
- case NavOp_Cancel:
- // No way of processing
- return No;
-
- default:
- GLOBALASSERT(0);
- }
- return No;
-}
-
-void
-RebMenus :: Item_Command :: Diagnostic(OurBool bSelected) const
-{
- textprint("Item_Command:");
-
- DiagnosticAppearance(bSelected);
-}
-// contains a command; can contain a "goto menu page" command
-
-// Methods relating to rendering:
-void
-RebMenus :: Item_Command :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- RenderAppearance
- (
- theContext,
- bSelected
- );
-}
-
-RebMenus :: SizeInfo
-RebMenus :: Item_Command :: GetSizeInfo(void) const
-{
- return AppearanceSizeInfo();
-}
-
-
-// class Item_Selection : public Item
-// public:
-#if 1
-// Process various keypresses:
-OurBool
-RebMenus :: Item_Selection :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
- switch ( aNavOp )
- {
- case NavOp_Up:
- if ( theDir == D_Vert )
- {
- Dec();
- return Yes;
- }
- else
- {
- return No;
- }
-
- case NavOp_Down:
- if ( theDir == D_Vert )
- {
- Inc();
- return Yes;
- }
- else
- {
- return No;
- }
-
- case NavOp_Left:
- if ( theDir == D_Horiz )
- {
- Dec();
- return Yes;
- }
- else
- {
- return No;
- }
-
- case NavOp_Right:
- if ( theDir == D_Horiz )
- {
- Inc();
- return Yes;
- }
- else
- {
- return No;
- }
- case NavOp_Home:
- Min();
- return Yes;
-
- case NavOp_End:
- Max();
- return Yes;
-
- case NavOp_Trigger:
- Inc();
- return Yes;
-
- case NavOp_Cancel:
- // No way of processing
- return No;
-
- default:
- GLOBALASSERT(0);
- }
- return No;
-}
-#endif
-
-void
-RebMenus :: Item_Selection :: Diagnostic(OurBool bSelected) const
-{
- textprint("Item_Selection: ");
-
- #if 1
- DiagnosticAppearance(bSelected);
- #endif
-
-}
-
-void
-RebMenus :: Item_Selection :: Min(void)
-{
- textprint("Min\n");
-
- pSelectionVar_Val -> Set
- (
- pSelectionVar_Val -> GetMin()
- );
-}
-
-void
-RebMenus :: Item_Selection :: Max(void)
-{
- textprint("Max\n");
-
- pSelectionVar_Val -> Set
- (
- pSelectionVar_Val -> GetMax()
- );
-}
-
-void
-RebMenus :: Item_Selection :: Inc(void)
-{
- textprint("Inc\n");
-
- pSelectionVar_Val -> Set
- (
- pSelectionVar_Val -> GetNxt()
- );
-
-}
-
-void
-RebMenus :: Item_Selection :: Dec(void)
-{
- textprint("Dec\n");
-
- pSelectionVar_Val -> Set
- (
- pSelectionVar_Val -> GetPrv()
- );
-}
-
-// Methods relating to rendering:
-void
-RebMenus :: Item_Selection :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- RenderAppearance
- (
- theContext,
- bSelected
- );
-
- RenderContext valueContext = theContext . NextColumn();
-
- pSelectionVar_Val -> GetAppearance( bSelected ) . Render
- (
- valueContext,
- bSelected
- );
-}
-
-RebMenus :: SizeInfo
-RebMenus :: Item_Selection :: GetSizeInfo(void) const
-{
- return AppearanceSizeInfo();
-}
-
-
-// class Item_Slider : public Item
-// public:
-// Process various keypresses:
-OurBool
-RebMenus :: Item_Slider :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
- switch ( aNavOp )
- {
- case NavOp_Up:
- if ( theDir == D_Vert )
- {
- Inc();
- return Yes;
- }
- else
- {
- return No;
- }
-
- case NavOp_Down:
- if ( theDir == D_Vert )
- {
- Dec();
- return Yes;
- }
- else
- {
- return No;
- }
-
- case NavOp_Left:
- if ( theDir == D_Horiz )
- {
- Dec();
- return Yes;
- }
- else
- {
- return No;
- }
-
- case NavOp_Right:
- if ( theDir == D_Horiz )
- {
- Inc();
- return Yes;
- }
- else
- {
- return No;
- }
- case NavOp_Home:
- SetToMax();
- return Yes;
-
- case NavOp_End:
- SetToMin();
- return Yes;
-
- case NavOp_Trigger:
- Inc();
- return Yes;
-
- case NavOp_Cancel:
- // No way of processing
- return No;
-
- default:
- GLOBALASSERT(0);
- }
- return No;
-}
-
-void
-RebMenus :: Item_Slider :: Diagnostic(OurBool bSelected) const
-{
- textprint("Item_Slider:");
-
- #if 1
- DiagnosticAppearance(bSelected);
- #endif
-}
-
-// Handy ways to process discrete movements of the slider
-void
-RebMenus :: Item_Slider :: SetToMin(void)
-{
- textprint("SetToMin\n");
-
- pBoundedExpVar_Val -> Set
- (
- pBoundedExpVar_Val -> GetMin()
- );
-}
-
-void
-RebMenus :: Item_Slider :: SetToMax(void)
-{
- textprint("SetToMax\n");
-
- pBoundedExpVar_Val -> Set
- (
- pBoundedExpVar_Val -> GetMax()
- );
-}
-
-void
-RebMenus :: Item_Slider :: Inc(void)
-{
- textprint("Inc\n");
-
- // The Set() method silently rejects attempt to set outside range
- // For this reason, if close to the bounding value,
- // set direct to bounding value
-
- int NewVal = pBoundedExpVar_Val -> Get() + GetFraction();
-
- int Bound = pBoundedExpVar_Val -> GetMax();
-
- pBoundedExpVar_Val -> Set
- (
- (NewVal < Bound) ? NewVal : Bound
- );
-}
-
-void
-RebMenus :: Item_Slider :: Dec(void)
-{
- textprint("Dec\n");
-
- // Analogous to the Inc() method above
-
- int NewVal = pBoundedExpVar_Val -> Get() - GetFraction();
-
- int Bound = pBoundedExpVar_Val -> GetMin();
-
- pBoundedExpVar_Val -> Set
- (
- (NewVal > Bound) ? NewVal : Bound
- );
-}
-
-// Methods relating to rendering:
-void
-RebMenus :: Item_Slider :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- RenderAppearance
- (
- theContext,
- bSelected
- );
-
- RenderContext sliderContext = theContext . NextColumn();
-
- float floatPos =
- (
- float( GetVal() - GetMin() )
- /
- float( GetRange() )
- );
-
- RenderSlider
- (
- sliderContext,
- bSelected,
- floatPos
- );
-
- #if 0
- textprintXY
- (
- sliderContext . Pos() . x,
- sliderContext . Pos() . y,
- " [%i,%i] range(%i) val(%i)",
- GetMin(),
- GetMax(),
- GetRange(),
- GetVal()
-
- );
- #endif
-}
-
-RebMenus :: SizeInfo
-RebMenus :: Item_Slider :: GetSizeInfo(void) const
-{
- return AppearanceSizeInfo() . AddColumn
- (
- SizeInfo
- (
- Bitmap :: GetSize("Graphics\\NewMenus\\SliderBar.rim"),
- 0
- )
- );
-}
-
-// private:
-// static
-void
-RebMenus :: Item_Slider :: RenderSlider
-(
- const RenderContext& theContext,
- OurBool bSelected,
- float floatAmount
-)
-{
- #if 1
- Bitmap :: Blit_Transparent
- (
- (
- bSelected
- ?
- "Graphics\\NewMenus\\SliderBar.rim" // const char* const pCh_Name,
- :
- "Graphics\\NewMenus\\SliderBarDark.rim" // const char* const pCh_Name,
- ),
- theContext . ClipRect(),
- theContext . Pos()
- );
- Bitmap :: Blit_Transparent
- (
- (
- bSelected
- ?
- "Graphics\\NewMenus\\Slider.rim" // const char* const pCh_Name,
- :
- "Graphics\\NewMenus\\SliderDark.rim" // const char* const pCh_Name,
- ),
- theContext . ClipRect(),
- r2pos
- (
- (
- theContext . Pos() . x + 3 +
- (
- int(200.0f * floatAmount)
- )
- ),
- (
- theContext . Pos() . y + 4
- )
- )
- );
- #else
- textprintXY
- (
- theContext . Pos() . x,
- theContext . Pos() . y,
- "[---------------]"
- );
-
- const int TotalWidth = (16*CharWidth);
- int Offset =
- (
- int(float(TotalWidth) * floatAmount)
- );
-
- textprintXY
- (
- theContext . Pos() . x + Offset,
- theContext . Pos() . y,
- "|"
- );
- #endif
-}
-
-
-// class Item_Toggle : public Item
-// public:
-// Process various keypresses:
-OurBool
-RebMenus :: Item_Toggle :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
- switch ( aNavOp )
- {
- case NavOp_Up:
- case NavOp_Down:
- if ( theDir == D_Vert )
- {
- Toggle();
- return Yes;
- }
- else
- {
- return No;
- }
- case NavOp_Left:
- case NavOp_Right:
- if ( theDir == D_Horiz )
- {
- Toggle();
- return Yes;
- }
- else
- {
- return No;
- }
- case NavOp_Trigger:
- Toggle();
- return Yes;
-
- case NavOp_Home:
- TurnOn();
- return Yes;
-
- case NavOp_End:
- TurnOff();
- return Yes;
-
- case NavOp_Cancel:
- // No way of processing
- return No;
-
- default:
- GLOBALASSERT(0);
- }
- return No;
-}
-
-void
-RebMenus :: Item_Toggle :: Diagnostic(OurBool bSelected) const
-{
- textprint("Item_Toggle:");
-
- DiagnosticAppearance(bSelected);
-
- theOnOffApp_Val . GetAppearance
- (
- pExpVar_Val -> Get()
- ) . Diagnostic();
-}
-
-void
-RebMenus :: Item_Toggle :: Toggle(void)
-{
- OurBool bCurrent = pExpVar_Val -> Get();
- pExpVar_Val -> Set
- (
- !bCurrent
- );
-}
-
-void
-RebMenus :: Item_Toggle :: TurnOn(void)
-{
- pExpVar_Val -> Set(Yes);
-}
-
-void
-RebMenus :: Item_Toggle :: TurnOff(void)
-{
- pExpVar_Val -> Set(No);
-}
-
-// Methods relating to rendering:
-void
-RebMenus :: Item_Toggle :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- RenderAppearance
- (
- theContext,
- bSelected
- );
-
-
- RenderContext valueContext = theContext . NextColumn();
-
- theOnOffApp_Val .GetAppearance
- (
- pExpVar_Val -> Get()
- ) . Render
- (
- valueContext,
- bSelected
- );
-}
-
-RebMenus :: SizeInfo
-RebMenus :: Item_Toggle :: GetSizeInfo(void) const
-{
- return AppearanceSizeInfo() . AddColumn
- (
- theOnOffApp_Val . GetSizeInfo()
- );
-}
-
-#if 0
-// class Item_Table : public Item
-// public:
-RebMenus :: Item_Table :: Item_Table
-(
- OnOffAppearance theOnOffApp_New
-) : Item(theOnOffApp_New),
- NumX(0),
- NumY(0),
- SelectedX(0),
- SelectedY(0)
-{
-}
-
-// Process various keypresses:
-OurBool
-RebMenus :: Item_Table :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
- return No;
-}
-
-void
-RebMenus :: Item_Table :: Diagnostic(OurBool bSelected) const
-{
-}
-
-Item*
-RebMenus :: Item_Table :: GetSelected(void) const
-{
- // will return NULL iff there are no items in the composition
- if (NumX == 0)
- {
- GLOBALASSERT(NumY==0);
- return NULL;
- }
-
- GLOBALASSERT( NumY > 0 );
-
- GLOBALASSERT( NumX < MAX_X );
- GLOBALASSERT( NumY < MAX_Y );
-
- GLOBALASSERT( SelectedX >= 0 );
- GLOBALASSERT( SelectedY >= 0 );
-
- GLOBALASSERT( SelectedX < NumX );
- GLOBALASSERT( SelectedY < NumY );
-
- Item* pItem = pItem_A[SelectedX][SelectedY];
-
- GLOBALASSERT( pItem );
-
- return pItem;
-}
-
-// private:
-void
-RebMenus :: Item_Table :: AddRow
-(
- Item** ppItem_ToAdd
-)
-{
- // takes a NULL-terminated list of Item*s
-
- GLOBALASSERT(NumY < (MAX_Y-1) );
- // can't get any bigger
-
- int Pos_I = 0;
-
- while ( *ppItem_ToAdd )
- {
- GLOBALASSERT( Pos_I < MAX_X );
-
- pItem_A
- [
- Pos_I++
- ]
- [
- NumY
- ]
- =
- (
- *(ppItem_ToAdd++)
- );
- }
-
- if (NumX < Pos_I)
- {
- }
-
- NumY++;
-
-}
-
-void
-RebMenus :: Item_Table :: AddColumn
-(
- Item** ppItem_ToAdd
-)
-{
- // takes a NULL-terminated list of Item*s
-}
-
-#if 0
-// List of selectables:
-enum {MAX_X = 10};
-enum {MAX_Y = 20};
-#endif
-
-#endif
-
-#endif
- // UseRebMenus
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/rebitems.hpp b/3dc/avp/support/rebitems.hpp
deleted file mode 100644
index 37ec9b2..0000000
--- a/3dc/avp/support/rebitems.hpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
-
- rebitems.hpp
-
- Derived classes for the item types; all except CompositeItem go in this
- file.
-*/
-
-#ifndef _rebitems_hpp
-#define _rebitems_hpp 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
- #ifndef _rebmenus_hpp
- #include "rebmenus.hpp"
- #endif
-
- #if UseRebMenus
- #ifndef _included_pcmenus_h_
- #include "pcmenus.h"
- // for enum KeyConfigItems
- #endif
-
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
- #endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-#if UseRebMenus
-// Derived classes for the item types:
-namespace RebMenus
-{
- class Item_Unimplemented : public Item
- {
- public:
- Item_Unimplemented
- (
- OnOffAppearance theOnOffApp
- ) : Item
- (
- theOnOffApp
- )
- {
- }
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- void Diagnostic(OurBool bSelected) const;
-
- // Methods relating to rendering:
- void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- SizeInfo GetSizeInfo(void) const;
-
- };
-
- class Item_Command : public Item
- {
- public:
- Item_Command
- (
- OnOffAppearance theOnOffApp,
- Command* pCommand
- ) : Item
- (
- theOnOffApp
- ),
- pCommand_Val(pCommand)
- {
- pCommand_Val -> R_AddRef();
- }
-
- ~Item_Command()
- {
- pCommand_Val -> R_Release();
- }
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- void Diagnostic(OurBool bSelected) const;
-
- // Methods relating to rendering:
- void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- SizeInfo GetSizeInfo(void) const;
-
- private:
- Command *const pCommand_Val;
- };
- // contains a command; can contain a "goto menu page" command
-
- class Item_Selection : public Item
- {
- public:
- Item_Selection
- (
- OnOffAppearance theOnOffApp,
- enum Direction initDir,
- SelectionVariable* pSelectionVar
- ) : Item
- (
- theOnOffApp
- ),
- theDir(initDir),
- pSelectionVar_Val(pSelectionVar)
- {
- }
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- void Diagnostic(OurBool bSelected) const;
-
- void Min(void);
- void Max(void);
- void Inc(void);
- void Dec(void);
-
- // Methods relating to rendering:
- void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- SizeInfo GetSizeInfo(void) const;
-
- private:
- // Direction:
- const enum Direction theDir;
- SelectionVariable* const pSelectionVar_Val;
-
- };
-
- class Item_Slider : public Item
- {
- public:
- Item_Slider
- (
- OnOffAppearance theOnOffApp,
- enum Direction initDir,
- BoundedExportVariable<int>* pBoundedExpVar
- // takes responsibility for deallocating this
- ) : Item
- (
- theOnOffApp
- ),
- theDir(initDir),
- pBoundedExpVar_Val(pBoundedExpVar)
- {
- }
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- void Diagnostic(OurBool bSelected) const;
-
- // Handy ways to process discrete movements of the slider
- void SetToMin(void);
- void SetToMax(void);
- void Inc(void);
- void Dec(void);
-
- // Handy ways to values of the slider:
- int GetMin(void) const
- {
- return pBoundedExpVar_Val -> GetMin();
- }
- int GetMax(void) const
- {
- return pBoundedExpVar_Val -> GetMax();
- }
- int GetRange(void) const
- {
- return ( GetMax() - GetMin() );
- }
- int GetVal(void) const
- {
- return pBoundedExpVar_Val -> Get();
- }
-
- // Methods relating to rendering:
- void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- SizeInfo GetSizeInfo(void) const;
-
- private:
- static void RenderSlider
- (
- const RenderContext& theContext,
- OurBool bSelected,
- float floatPos
- );
-
- int GetFraction(void) const
- {
- // returns a fractional amout good for a small increment/decrement
-
- int Amt = (GetRange() / 32);
-
- return ( (Amt>1) ? Amt : 1);
- // ensure amount is at least 1
- }
-
- private:
- // Direction:
- const enum Direction theDir;
- BoundedExportVariable<int>* const pBoundedExpVar_Val;
-
- };
-
- class Item_Toggle : public Item
- {
- public:
- Item_Toggle
- (
- OnOffAppearance theOnOffApp_Label,
-
- enum Direction initDir,
- OnOffAppearance theOnOffApp_Choice,
- ExportVariable<OurBool>* pExpVar
- // takes responsibility for deallocating this
- ) : Item
- (
- theOnOffApp_Label
- ),
- theDir(initDir),
- theOnOffApp_Val(theOnOffApp_Choice),
- pExpVar_Val(pExpVar)
- {
- }
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- void Diagnostic(OurBool bSelected) const;
-
- void Toggle(void);
- void TurnOn(void);
- void TurnOff(void);
-
- // Methods relating to rendering:
- void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- SizeInfo GetSizeInfo(void) const;
-
- private:
- // Direction:
- const enum Direction theDir;
-
- OnOffAppearance theOnOffApp_Val;
-
- ExportVariable<OurBool>* pExpVar_Val;
- };
-
- #if 0
- // A 2d analogue of the composite item:
- class Item_Table : public Item
- {
- public:
- Item_Table
- (
- OnOffAppearance theOnOffApp_New
- );
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- void Diagnostic(OurBool bSelected) const;
-
- Item* GetSelected(void) const;
- // will return NULL iff there are no items in the composition
-
- private:
- #if 1
- void AddControlConfigRow();
- #else
- void AddRow
- (
- Item** ppItem_ToAdd
- );
- // takes a NULL-terminated list of Item*s
-
- void AddColumn
- (
- Item** ppItem_ToAdd
- );
- // takes a NULL-terminated list of Item*s
- #endif
-
- // List of selectables:
- enum {MAX_X = 10};
- enum {MAX_Y = 20};
-
- int NumX;
- int NumY;
- Item* pItem_A[ MAX_X ][ MAX_Y ];
-
- int SelectedX;
- int SelectedY;
-
- };
- #endif
-
-
- #if 0
- // Decorator contains another item, and passes on calls to it ??
- class Item_Decorator_VScroll : public Item
- {
- public:
- private:
- };
- #endif
-
-};
-#endif // UseRebMenus
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-#endif
diff --git a/3dc/avp/support/rebmenus.cpp b/3dc/avp/support/rebmenus.cpp
deleted file mode 100644
index 4581a82..0000000
--- a/3dc/avp/support/rebmenus.cpp
+++ /dev/null
@@ -1,1722 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: rebmenus.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 9/3/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-
- #include "rebmenus.hpp"
-
- #if UseRebMenus
- #include "rebitems.hpp"
- #include "strtab.hpp"
- #include "indexfnt.hpp"
-
- #include "awTexLd.h"
- #include "alt_tab.h"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
- #endif // UseRebMenus
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#if UseRebMenus
- #ifdef __cplusplus
- extern "C"
- {
- #endif
-
- extern LPDIRECTDRAWSURFACE lpDDSBack;
-
- #ifdef __cplusplus
- };
- #endif
-#endif // UseRebMenus
-
-
-/* Exported globals ************************************************/
-#if UseRebMenus
-#if OverrideOldMenus
-// private:
-// static
-OurBool RebMenus :: InGame :: bInTheGame_Val = No;
-
-// static
-
-// enum RebMenus :: MenuLoop :: ExitReason
-// enum ExitReason
-RebMenus :: MenuLoop :: ExitReason
-RebMenus :: MenuLoop :: theExitReason_Val = ExitReason_None;
-#endif
- // OverrideOldMenus
-#endif
- // UseRebMenus
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-#if UseRebMenus
-// namespace RebMenus
-// class Command_JumpToPage : public Command
-// public:
-OurBool
-RebMenus :: Command_JumpToPage :: Execute(void)
-{
- Page :: SelectPage(thePage_Val);
-
- return Yes;
-}
-
-
-// class Command_ReturnFromPage : public Command
-// public:
-OurBool
-RebMenus :: Command_ReturnFromPage :: Execute(void)
-{
- Page :: TryToReturn();
-
- return Yes;
-}
-
-RebMenus :: SizeInfo
-RebMenus :: SizeInfo :: Overlay
-(
- SizeInfo other
-)
-{
- int minW_Max =
- (
- (minR2Size_Val . w > other . minR2Size_Val . w)
- ?
- minR2Size_Val . w
- :
- other . minR2Size_Val . w
- );
- int minH_Max =
- (
- (minR2Size_Val . h > other . minR2Size_Val . h)
- ?
- minR2Size_Val . h
- :
- other . minR2Size_Val . h
- );
- int maxColumn_minW =
- (
- (Column0_minW_Val > other . Column0_minW_Val)
- ?
- Column0_minW_Val
- :
- other . Column0_minW_Val
- );
- return SizeInfo
- (
- r2size
- (
- minW_Max,
- minH_Max
- ),
- maxColumn_minW
- );
-}
-
-RebMenus :: SizeInfo
-RebMenus :: SizeInfo :: AddColumn
-(
- SizeInfo nextColumn
-)
-{
- r2size R2Size_New = minR2Size_Val;
- r2size R2Size_NextColumn = nextColumn . minR2Size_Val;
-
- R2Size_New . HCompose
- (
- R2Size_NextColumn
- );
-
- return SizeInfo
- (
- R2Size_New,
- minR2Size_Val . w
- );
-}
-
-RebMenus :: SizeInfo
-RebMenus :: SizeInfo :: AddRow
-(
- SizeInfo nextRow
-)
-{
- r2size R2Size_New = minR2Size_Val;
-
- int maxColumn_minW =
- (
- (Column0_minW_Val > nextRow . Column0_minW_Val)
- ?
- Column0_minW_Val
- :
- nextRow . Column0_minW_Val
- );
-
- R2Size_New . VCompose(nextRow . minR2Size_Val);
-
- return SizeInfo
- (
- R2Size_New,
- maxColumn_minW
- );
-}
-
-#if 1
-void
-RebMenus :: SizeInfo :: Compose
-(
- const SizeInfo& other,
- enum Direction theD,
- enum Alignment // theAl
-)
-{
- if ( theD == D_Vert )
- {
- minR2Size_Val . VCompose
- (
- other . minR2Size_Val
- );
- }
- else
- {
- minR2Size_Val . HCompose
- (
- other . minR2Size_Val
- );
- }
-
- Column0_minW_Val =
- (
- (Column0_minW_Val > other . Column0_minW_Val)
- ?
- Column0_minW_Val
- :
- other . Column0_minW_Val
- );
-}
-
-
-#endif
-
-
-
-// class Appearance
-// public:
-void
-RebMenus :: Appearance :: Diagnostic(void) const
-{
- if ( bHasBitmap )
- {
- textprint("bitmap:\"%s\"; ",BMapN_Val . Get());
- }
- else
- {
- textprint("plain; ");
- }
-
- if ( bHasTextLabel )
- {
- SCString& theLabel = StringTable :: GetSCString
- (
- ID_Label_Val
- );
-
- textprint
- (
- "label=\"%s\"\n",
- theLabel . pProjCh()
- );
-
- theLabel . R_Release();
- }
- else
- {
- textprint("unlabelled\n");
- }
-}
-
-// Methods relating to rendering:
-void
-RebMenus :: Appearance :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- if
- (
- bSelected
- )
- {
- textprintXY
- (
- theContext . Pos() . x-20,
- theContext . Pos() . y,
- "*"
- );
- }
-
- if ( bHasTextLabel )
- {
- SCString& theLabel = StringTable :: GetSCString
- (
- ID_Label_Val
- );
-
- #if 1
- IndexedFont* pFont = IndexedFont :: GetFont
- (
- Fonts :: GetIndex
- (
- bSelected
- )
- );
- // can return NULL if no font loaded in that slot
- GLOBALASSERT( pFont );
-
- r2pos R2Pos_Cursor = theContext . Pos();
-
- pFont -> RenderString_Clipped
- (
- R2Pos_Cursor,
- theContext . ClipRect(),
- Label_FixP_Alpha,
- theLabel
- );
- #else
- textprintXY
- (
- theContext . Pos() . x,
- theContext . Pos() . y,
- theLabel . pProjCh()
- );
- #endif
-
- theLabel . R_Release();
-
- }
-
- if ( bHasBitmap )
- {
- #if 1
- textprintXY
- (
- theContext . Pos() . x,
- theContext . Pos() . y,
- "bitmap:\"%s\"; ",
- BMapN_Val . Get()
- );
- #endif
-
- Bitmap :: Blit_Transparent
- (
- BMapN_Val . Get(), // const char* const pCh_Name,
- theContext . ClipRect(), // r2rect R2Rect_Clip,
- theContext . Pos() // r2pos dstR2Pos
- );
- }
-}
-
-RebMenus :: SizeInfo
-RebMenus :: Appearance :: GetSizeInfo(void) const
-{
- r2size runningR2Size;
- int runningColumn0;
-
- if ( bHasTextLabel )
- {
- SCString& theLabel = StringTable :: GetSCString
- (
- ID_Label_Val
- );
-
- r2size R2Size_Label = theLabel . CalcSize
- (
- Fonts :: GetIndex
- (
- Yes
- // for the moment
- )
- );
-
- theLabel . R_Release();
-
- runningR2Size = R2Size_Label;
- runningColumn0 = R2Size_Label . w + ColumnSpacing;
- }
- else
- {
- runningR2Size = r2size(0,0);
- runningColumn0 = 0;
- }
-
- SizeInfo theSizeInfo
- (
- runningR2Size,
- runningColumn0
- );
-
- if ( bHasBitmap )
- {
- theSizeInfo = theSizeInfo . Overlay
- (
- SizeInfo
- (
- Bitmap :: GetSize
- (
- BMapN_Val . Get()
- ),
- 0
- )
- );
- }
-
- return theSizeInfo;
-}
-
-RebMenus :: SizeInfo
-RebMenus :: OnOffAppearance :: GetSizeInfo(void) const
-{
- SizeInfo SizeInfo_On = App_On_Val . GetSizeInfo();
- SizeInfo SizeInfo_Off = App_Off_Val . GetSizeInfo();
-
- return SizeInfo_On . Overlay(SizeInfo_Off);
-}
-
-
-void
-RebMenus :: Item :: DiagnosticAppearance(OurBool bSelected) const
-{
- theOnOffApp_Val . GetAppearance(bSelected) . Diagnostic();
-}
-
-
-
-// Combined factory/"add to list" methods:
-RebMenus :: Item_Unimplemented*
-RebMenus :: CompositeItem :: AddUnimplementedItem
-(
- OnOffAppearance theOnOffApp
-)
-{
- Item_Unimplemented* pItem = new Item_Unimplemented
- (
- theOnOffApp
- );
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: Item_Command*
-RebMenus :: CompositeItem :: AddNewCommandItem
-(
- OnOffAppearance theOnOffApp,
- Command* pCommand
-)
-{
- GLOBALASSERT( pCommand );
-
- Item_Command* pItem = new Item_Command
- (
- theOnOffApp,
- pCommand
- );
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: Item_Command*
-RebMenus :: CompositeItem :: AddNewJumpItem
-(
- OnOffAppearance theOnOffApp,
- enum PageID theDst
-)
-{
- Command_JumpToPage* pCommand = new Command_JumpToPage
- (
- theDst
- );
-
- Item_Command* pItem = new Item_Command
- (
- theOnOffApp,
- pCommand
- );
-
- pCommand -> R_Release();
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: Item_Selection*
-RebMenus :: CompositeItem :: AddNewSelectionItem
-(
- OnOffAppearance theOnOffApp,
- enum Direction initDir,
- SelectionVariable* pSelectionVar
-)
-{
- Item_Selection* pItem = new Item_Selection
- (
- theOnOffApp,
- initDir,
- pSelectionVar
- );
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: Item_Slider*
-RebMenus :: CompositeItem :: AddNewSliderItem
-(
- OnOffAppearance theOnOffApp,
- enum Direction initDir,
- BoundedExportVariable<int>* pBoundedExpVar
-)
-{
- Item_Slider* pItem = new Item_Slider
- (
- theOnOffApp,
- initDir,
- pBoundedExpVar
- );
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: Item_Toggle*
-RebMenus :: CompositeItem :: AddNewToggleItem
-(
- OnOffAppearance theOnOffApp_Label,
- enum Direction initDir,
- OnOffAppearance theOnOffApp_Choice,
- ExportVariable<OurBool>* pExpVar
-)
-{
- Item_Toggle* pItem = new Item_Toggle
- (
- theOnOffApp_Label,
- initDir,
- theOnOffApp_Choice,
- pExpVar
- );
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: CompositeItem*
-RebMenus :: CompositeItem :: AddNewCompositeItem
-(
- OnOffAppearance theOnOffApp,
- enum Direction theD,
- enum Alignment theAlignment_New
-)
-{
- CompositeItem* pItem = new CompositeItem
- (
- theOnOffApp,
- theD,
- theAlignment_New
- );
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-RebMenus :: Item*
-RebMenus :: CompositeItem :: AddNewCancelItem
-(
- OnOffAppearance theOnOffApp
-)
-{
- Command_ReturnFromPage* pCommand = new Command_ReturnFromPage();
-
- Item* pItem = new Item_Command
- (
- theOnOffApp,
- pCommand
- );
-
- pCommand -> R_Release();
-
- AddToList
- (
- pItem
- );
-
- return pItem;
-}
-
-void
-RebMenus :: CompositeItem :: AddNewItem_Special(Item* pItem)
-{
- GLOBALASSERT(pItem);
-
- AddToList(pItem);
-}
-
-
-// Process various keypresses:
-OurBool
-RebMenus :: CompositeItem :: Navigate( enum NavigationOp aNavOp )
-{
- // return = was message processed
-
- if ( NumItems >0 )
- {
- // Pass to selected child for processing:
- if
- (
- !( GetSelected() -> Navigate( aNavOp ) )
- )
- {
- // then selected child couldn't process it, this composite should have a go:
- switch ( aNavOp )
- {
- case NavOp_Up:
- {
- if ( theDir == D_Vert )
- {
- if ( SelectedItem > 0)
- {
- SelectedItem--;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- if ( Wraparound :: bEnabled() )
- {
- SelectedItem = NumItems-1;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- return No;
- }
- }
- }
- else
- {
- return No;
- }
- }
- case NavOp_Down:
- {
- if ( theDir == D_Vert )
- {
- if ( SelectedItem < (NumItems-1))
- {
- SelectedItem++;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- if ( Wraparound :: bEnabled() )
- {
- SelectedItem = 0;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- return No;
- }
- }
- }
- else
- {
- return No;
- }
- }
-
- case NavOp_Left:
- {
- if ( theDir == D_Horiz )
- {
- if ( SelectedItem > 0)
- {
- SelectedItem--;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- if ( Wraparound :: bEnabled() )
- {
- SelectedItem = NumItems-1;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- return No;
- }
- }
- }
- else
- {
- return No;
- }
- }
- case NavOp_Right:
- {
- if ( theDir == D_Horiz )
- {
- if ( SelectedItem < (NumItems-1))
- {
- SelectedItem++;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- if ( Wraparound :: bEnabled() )
- {
- SelectedItem = 0;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
- else
- {
- return No;
- }
- }
- }
- else
- {
- return No;
- }
- }
-
- case NavOp_Home:
- {
- SelectedItem=0;
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
-
- case NavOp_End:
- {
- SelectedItem=(NumItems-1);
- GetSelected() -> Selected_Hook
- (
- aNavOp
- );
- return Yes;
- }
-
- case NavOp_Trigger:
- {
- return No;
- }
-
- case NavOp_Cancel:
- {
- Page :: TryToReturn();
- return Yes;
- }
-
- default:
- GLOBALASSERT(0);
- }
- }
- }
- // else: no items to navigate
-
- if ( aNavOp == NavOp_Cancel )
- {
- // don't need any items for this to work
- Page :: TryToReturn();
- return Yes;
- }
-
-
- return No;
-
-}
-
-void
-RebMenus :: CompositeItem :: Diagnostic(OurBool bSelected) const
-{
- {
- textprint("CompositeItem ::Diagnostic()... ");
-
- DiagnosticAppearance(bSelected);
- }
-
- textprint("NumItems=%i\n",NumItems);
-
- for (int i=0;i<NumItems;i++)
- {
- textprint
- (
- (i==SelectedItem)
- ?
- "-->"
- :
- " "
- );
-
- pItem_A[i]->Diagnostic(i==SelectedItem);
- // or should the "selected" nature also depend on whether the
- // parent is selected?
- }
-}
-
-RebMenus :: Item*
-RebMenus :: CompositeItem :: GetSelected(void) const
-{
- // will return NULL iff there are no items in the composition
- if (NumItems>0)
- {
- return pItem_A[SelectedItem];
- }
- else
- {
- return NULL;
- }
-}
-
-// Methods relating to rendering:
-void
-RebMenus :: CompositeItem :: Render
-(
- const RenderContext& theContext,
- OurBool bSelected
-) const
-{
- r2size R2Size_Composite = GetSizeInfo() . GetMin();
- int nonIterationAxisSize_Composite =
- (
- theDir == D_Vert
- ?
- R2Size_Composite . w
- :
- R2Size_Composite . h
- );
-
- // Always render appearance (the title) centred
- {
- SizeInfo titleSizeInfo = AppearanceSizeInfo();
-
- r2pos titlePos = theContext . Pos();
-
- if ( theDir == D_Vert )
- {
- titlePos . x += ( R2Size_Composite . w - titleSizeInfo . GetMin() . w)/2;
- }
- else
- {
- titlePos . y += ( R2Size_Composite . h - titleSizeInfo . GetMin() . h)/2;
- }
-
- RenderContext titleContext = RenderContext
- (
- theContext . ClipRect(), // r2rect R2Rect_Clip_New,
- titlePos, // r2pos R2Pos_At_New,
- // top-left hotspot
- 0 // int Column0_W_New
- // width of 1st column
- );
-
- RenderAppearance
- (
- titleContext,
- bSelected
- );
- }
-
-
- // Iterate through items, calling Render():
- r2pos R2Pos_I
- (
- theContext . Pos()
- );
-
- // Adjust position for any title:
- {
- SizeInfo titleSizeInfo = AppearanceSizeInfo();
-
- if ( theDir == D_Horiz )
- {
- R2Pos_I . x += titleSizeInfo . GetMin() . w + ItemSpacing();
- }
- else
- {
- R2Pos_I . y += titleSizeInfo . GetMin() . h + ItemSpacing();
- }
- }
-
- #if 0
- SizeInfo thisSizeInfo = GetSizeInfo();
-
- R2Pos_I . x -= (thisSizeInfo . GetMin() . w/2);
- R2Pos_I . y -= (thisSizeInfo . GetMin() . h/2);
- #endif
-
- for (int i=0;i<NumItems;i++)
- {
- textprintXY(R2Pos_I.x,R2Pos_I.y,"%i",i);
-
- int theIterationAxisPos_I =
- (
- theDir == D_Vert
- ?
- R2Pos_I . y
- :
- R2Pos_I . x
- );
- int nonIterationAxisPos_I =
- (
- theDir == D_Vert
- ?
- R2Pos_I . x
- :
- R2Pos_I . y
- );
-
- r2size R2Size_I = pItem_A[i] -> GetSizeInfo() . GetMin();
-
- int nonIterationAxisSize_I =
- (
- theDir == D_Vert
- ?
- R2Size_I . w
- :
- R2Size_I . h
- );
-
- switch ( theAlignment_Val )
- {
- case Align_Min:
- {
- // means "left-aligned" for V-composition, "top-aligned" for H-Composition
- // so leave untouched
- }
- break;
-
- case Align_Centre:
- {
- // means "centred about X" for V-composition, "centred about Y" for H-Composition
- // so centre the nonIterationAxis
- nonIterationAxisPos_I += ( nonIterationAxisSize_Composite - nonIterationAxisSize_I)/2;
- // could be negative; this equation ought to still be valid
- }
- break;
-
- case Align_Max:
- {
- // increase the nonIterationAxis to maximal value that will fit
- nonIterationAxisPos_I += ( nonIterationAxisSize_Composite - nonIterationAxisSize_I);
- // could be negative; this equation ought to still be valid
- }
- break;
-
- default:
- GLOBALASSERT(0);
- break;
- }
-
- r2pos R2Pos_ToUse =
- (
- theDir == D_Vert
- ?
- r2pos( nonIterationAxisPos_I, theIterationAxisPos_I )
- :
- r2pos( theIterationAxisPos_I, nonIterationAxisPos_I )
- );
-
- RenderContext yourContext
- (
- theContext.ClipRect(), // r2rect R2Rect_Clip_New,
- R2Pos_ToUse, // r2pos R2Pos_At_New
- theContext.Column0_W()
- );
-
- pItem_A[i] -> Render
- (
- yourContext,
- (
- bSelected && (SelectedItem == i)
- )
- );
-
- if ( theDir == D_Horiz )
- {
- R2Pos_I . x += R2Size_I . w + ItemSpacing();
- }
- else
- {
- R2Pos_I . y += R2Size_I . h + ItemSpacing();
- }
- }
-}
-
-RebMenus :: SizeInfo
-RebMenus :: CompositeItem :: GetSizeInfo(void) const
-{
- SizeInfo SizeInfo_ToReturn
- (
- #if 1
- r2size(0,0),
- 0
- #else
- AppearanceSizeInfo() . GetMin(),
- AppearanceSizeInfo() . GetColumn0_minW()
- #endif
- );
-
- for (int i=0;i<NumItems;i++)
- {
- SizeInfo itemSizeInfo = pItem_A[i] -> GetSizeInfo();
-
- #if 1
- SizeInfo_ToReturn . Compose
- (
- itemSizeInfo,
- theDir,
- theAlignment_Val
- );
-
- #else
-
- r2size ItemSize_Min = itemSizeInfo . GetMin();
-
- if ( theDir == D_Horiz )
- {
- AppSize_Min . HCompose
- (
- ItemSize_Min
- );
-
- if (i!=0)
- {
- AppSize_Min . w += ItemSpacing();
- }
- }
- else
- {
- AppSize_Min . VCompose
- (
- ItemSize_Min
- );
-
- if ( max_Column0_minW < itemSizeInfo . GetColumn0_minW() )
- {
- max_Column0_minW = itemSizeInfo . GetColumn0_minW();
- }
-
- if (i!=0)
- {
- AppSize_Min . h += ItemSpacing();
- }
- }
- #endif
- }
-
- #if 1
- return SizeInfo_ToReturn;
- #else
- return SizeInfo
- (
- AppSize_Min,
- max_Column0_minW
- );
- #endif
-}
-
-
-// private:
-void
-RebMenus :: CompositeItem :: AddToList
-(
- Item* pItem_ToAdd
-)
-{
- GLOBALASSERT(NumItems < MAX_ITEMS_PER_LIST );
-
- pItem_A[ NumItems++ ] = pItem_ToAdd;
-
-
- if (NumItems == 1)
- {
- // then this was the first item added:
- SelectedItem = 0;
- }
-}
-
-// static
-int RebMenus :: CompositeItem :: ItemSpacing(void)
-{
- return 2;
-}
-
-
-void
-RebMenus :: Page :: MiniStack :: Push(enum PageID in)
-{
- if (NumItems < NUM_PAGES_MEMORY)
- {
- theA[ NumItems++ ] = in;
- }
- else
- {
- // one falls off the bottom; shuffle everything up
- GLOBALASSERT( NumItems == NUM_PAGES_MEMORY );
-
- for (int i=0;i<(NUM_PAGES_MEMORY-1);i++)
- {
- theA[i] = theA[i+1];
- }
-
- // ...and set the end element:
- theA[NUM_PAGES_MEMORY-1] = in;
- }
-}
-
-OurBool
-RebMenus :: Page :: MiniStack :: Pop(enum PageID& out)
-{
- // return value: was there anything?
- if ( NumItems > 0)
- {
- out = theA[--NumItems];
- return Yes;
- }
- else
- {
- return No;
- }
-}
-
-void
-RebMenus :: Page :: MiniStack :: Diagnostic(void)
-{
- textprint("page stack: num pages = %i\n",NumItems);
-
- for (int i=0;i<NumItems;i++)
- {
- textprint("entry:%2i page=%2i\n",i,theA[i]);
- }
-}
-
-void
-RebMenus :: Page :: MiniStack :: Clear(void)
-{
- NumItems = 0;
-}
-
-
-
-// protected:
-RebMenus :: Page :: Page
-(
- Appearance theApp_New,
- enum Direction theD,
- enum Alignment theAlignment_New,
- PageID theID
-) : CompositeItem
- (
- OnOffAppearance
- (
- theApp_New,
- theApp_New
- ),
- // for the moment, menu pages have identical appearances whether
- // selected or not. Would only make a difference if deselected pages
- // animate away rather than instantly vanish
- theD,
- theAlignment_New
- ),
- theID_Val(theID)
-{
- GLOBALASSERT( pPage[theID_Val] == NULL );
-
- pPage[theID_Val] = this;
-}
-RebMenus :: Page :: ~Page()
-{
- GLOBALASSERT( pPage[theID_Val] == this );
-
- pPage[theID_Val] = NULL;
-}
-
-void
-RebMenus :: Page :: Diagnostic(OurBool bSelected) const
-{
- thePageStack . Diagnostic();
-
- textprint("Menu page:%i\n",theID_Val);
-
- CompositeItem :: Diagnostic(bSelected);
-}
-
-// static
-// static
-void
-RebMenus :: Page :: SelectPage(enum PageID inID)
-{
- GLOBALASSERT(inID>=0);
- GLOBALASSERT(inID<NUM_PAGE_IDS);
-
- thePageStack . Push( SelectedPageID );
-
- Internal_SelectPage_NoPush( inID );
-}
-
-// static
-void
-RebMenus :: Page :: SelectPage_ClearingStack(enum PageID inID)
-{
- GLOBALASSERT(inID>=0);
- GLOBALASSERT(inID<NUM_PAGE_IDS);
-
- // Clear page stack:
- thePageStack . Clear();
-
- // Select page:
- Internal_SelectPage_NoPush( inID );
-}
-
-// static
-void
-RebMenus :: Page :: TryToReturn(void)
-{
- enum PageID popPage;
-
- if
- (
- !thePageStack . Pop
- (
- popPage
- )
- )
- {
- textprint("empty page stack; picking initial menu\n");
- #if 1
- popPage = PageID_Initial;
- #else
- popPage = PageID_NoMenu;
- #endif
- }
-
- // Set page, without pushing where we were:
- {
- Internal_SelectPage_NoPush( popPage );
- }
-}
-
-
-RebMenus :: Page*
-RebMenus :: Page :: Get(enum PageID inID)
-{
- return pPage[ inID ];
-}
-
-// static
-RebMenus :: Page*
-RebMenus :: Page :: GetSelected(void)
-{
- return Get(SelectedPageID);
-}
-
-// private:
-// static
-void
-RebMenus :: Page :: Internal_SelectPage_NoPush( enum PageID inID )
-{
- // Worker function to call hooks and actually change the page
- // Used by SelectPage() and TryToReturn()
- // Doesn't push current page onto page stack
-
- // Call hook for leaving the current page:
- GetSelected() -> Hook_LeavingPage();
-
- // Set the all-important variable:
- SelectedPageID = inID;
-
- // Call hook for entering the new page:
- GetSelected() -> Hook_EnteringPage();
-}
-
-
-// private:
-// static
-RebMenus :: Page* RebMenus :: Page :: pPage[ NUM_PAGE_IDS ];
-// static
-enum PageID RebMenus :: Page :: SelectedPageID = PageID_Initial;
-// static
-RebMenus :: Page :: MiniStack
-RebMenus :: Page :: thePageStack;
-
-
-// class Wraparound
-// static
-const OurBool RebMenus :: Wraparound :: bEnabled_Val = Yes;
-
-// Globals within RebMenus:
-void RebMenus :: Init(void)
-{
- ProjectSpecific :: Init();
-}
-
-void RebMenus :: UnInit(void)
-{
- ProjectSpecific :: UnInit();
-
- // Destroy all menu pages:
- {
-
- }
-}
-
-void RebMenus :: Maintain(void)
-{
- textprint("RebMenus::Maintain()\n");
-
- ProjectSpecific :: Maintain();
-
- #if 1
- {
- Page* pPage = Page :: GetSelected();
- GLOBALASSERT( pPage );
-
- pPage -> Diagnostic(Yes);
- }
- #endif
-}
-
-// static
-void
-RebMenus :: Render(void)
-{
- textprint("RebMenus :: Render()\n");
-
- Page* pPage = Page :: GetSelected();
- GLOBALASSERT( pPage );
-
- SizeInfo theSizeInfo = pPage -> GetSizeInfo();
-
- pPage -> Render
- (
- RenderContext
- (
- r2rect::PhysicalScreen(), // r2rect R2Rect_Clip_New,
-
- r2rect::PhysicalScreen() . CentredWithSize_TL
- (
- theSizeInfo . GetMin()
- ), // r2pos R2Pos_At_New
-
- theSizeInfo . GetColumn0_minW() // int Column0_W_New
- ),
- Yes //OurBool bSelected
- );
-}
-
-
-// namespace Bitmap
-namespace RebMenus
-{
- namespace Bitmap
- {
- class Implementation
- {
- private:
- class CacheEntry
- {
- public:
- CacheEntry
- (
- const char* const pCh_Name_New
- );
- ~CacheEntry();
-
- static void Empty(void)
- {
- while (List_pCacheEntry . size() > 0)
- {
- delete List_pCacheEntry . first_entry();
- }
- }
-
- void Blit_Transparent
- (
- r2rect R2Rect_Clip,
- r2pos dstR2Pos
- );
-
- r2size GetSize(void) const
- {
- return R2Size;
- }
-
- static CacheEntry* Get(const char* const pCh_Name);
-
- private:
- const char* const pCh_Name_Val;
- LPDIRECTDRAWSURFACE pSurface;
- AW_BACKUPTEXTUREHANDLE hBackup;
- r2size R2Size;
-
- static List<CacheEntry*> List_pCacheEntry;
- // maintains a set of all of these
- // really ought to do this as a hash table (potentially using Jake's
- // template), but no need for the moment
- };
- private:
-
-
-
- public:
- static void Precache(const char* const pCh_Name)
- {
- new CacheEntry(pCh_Name);
- }
-
- static void UnCache(const char* const pCh_Name)
- {
- CacheEntry* pEntry = CacheEntry :: Get(pCh_Name);
-
- if (!pEntry) { return; }
-
- delete pEntry;
- }
-
- static void EmptyCache(void)
- {
- CacheEntry :: Empty();
- }
-
- static void Blit_Transparent
- (
- const char* const pCh_Name,
- r2rect R2Rect_Clip,
- r2pos dstR2Pos
- )
- {
- CacheEntry* pEntry = CacheEntry :: Get(pCh_Name);
-
- if (!pEntry)
- {
- pEntry = new CacheEntry(pCh_Name);
- }
-
- GLOBALASSERT( pEntry );
-
- pEntry -> Blit_Transparent
- (
- R2Rect_Clip,
- dstR2Pos
- );
- }
- static r2size GetSize(const char* const pCh_Name)
- {
- CacheEntry* pEntry = CacheEntry :: Get(pCh_Name);
-
- if (!pEntry)
- {
- pEntry = new CacheEntry(pCh_Name);
- }
-
- GLOBALASSERT( pEntry );
-
- return pEntry -> GetSize();
- }
-
- };
- };
-};
-
-RebMenus :: Bitmap :: Implementation :: CacheEntry :: CacheEntry
-(
- const char* const pCh_Name_New
-) : pCh_Name_Val(pCh_Name_New)
-{
- unsigned nWidth,nHeight;
-
- pSurface = AwCreateSurface
- (
- "sfXYB",
- pCh_Name_Val,
- (
- 0
- ), // flags
- &nWidth,
- &nHeight,
- &hBackup
- );
- ATIncludeSurface(pSurface,hBackup);
-
-
- R2Size . w = nWidth;
- R2Size . h = nHeight;
-
- List_pCacheEntry . add_entry(this);
-}
-
-RebMenus :: Bitmap :: Implementation :: CacheEntry :: ~CacheEntry()
-{
- List_pCacheEntry . delete_entry(this);
-
- GLOBALASSERT(pSurface);
- ATRemoveSurface(pSurface);
- ReleaseDDSurface(pSurface);
- pSurface = NULL;
-
- if (hBackup)
- {
- AwDestroyBackupTexture(hBackup);
- }
-
- hBackup = NULL;
-
-}
-
-void
-RebMenus :: Bitmap :: Implementation :: CacheEntry :: Blit_Transparent
-(
- r2rect R2Rect_Clip,
- r2pos dstR2Pos
-)
-{
- if
- (
- r2rect
- (
- dstR2Pos,
- GetSize()
- ) . bFitsIn( R2Rect_Clip )
- )
- {
- RECT destRect;
-
- destRect.left = dstR2Pos . x;
- destRect.top = dstR2Pos . y;
-
- destRect.right = dstR2Pos . x + R2Size . w;
- destRect.bottom = dstR2Pos . y + R2Size . h;
-
-
- RECT srcRect;
-
- srcRect.left =0;
- srcRect.top =0;
- srcRect.right = R2Size . w;
- srcRect.bottom = R2Size . h;
-
- #if 1
- DDBLTFX tempDDBltFx;
-
- memset(&tempDDBltFx,0,sizeof(DDBLTFX));
-
- tempDDBltFx . dwSize = sizeof(DDBLTFX);
- tempDDBltFx . ddckSrcColorkey . dwColorSpaceLowValue = 0;
- tempDDBltFx . ddckSrcColorkey . dwColorSpaceHighValue = 0;
- #endif
-
- HRESULT ddrval = lpDDSBack->Blt
- (
- &destRect,
- pSurface,
- #if 1
- NULL,
- #else
- &srcRect,
- #endif
- (
- DDBLT_WAIT
- #if 0
- | DDBLT_KEYSRC
- #else
- | DDBLT_KEYSRCOVERRIDE
- #endif
- ),
- &tempDDBltFx // LPDDBLTFX lpDDBltFx
- );
-
- #if 0
- if(ddrval != DD_OK)
- {
- ReleaseDirect3D();
- exit(0x666009);
- }
- #endif
- }
- // else reject as I can't be bothered to write clipping code
-}
-
-// static
-RebMenus :: Bitmap :: Implementation :: CacheEntry*
-RebMenus :: Bitmap :: Implementation :: CacheEntry :: Get(const char* const pCh_Name)
-{
- GLOBALASSERT( pCh_Name );
-
- // A simple linear search for now:
- for
- (
- LIF<CacheEntry*>oi(&List_pCacheEntry);
- !oi . done();
- oi . next()
- )
- {
- if
- (
- strcmp
- (
- pCh_Name,
- oi() -> pCh_Name_Val
- ) == 0
- )
- {
- return oi();
- }
- }
- return NULL;
-}
-
-// static
-List<RebMenus :: Bitmap :: Implementation :: CacheEntry*>
-RebMenus :: Bitmap :: Implementation :: CacheEntry :: List_pCacheEntry;
-
-
-void
-RebMenus :: Bitmap :: Precache(const char* const pCh_Name)
-{
- GLOBALASSERT( pCh_Name );
-
- Implementation :: Precache(pCh_Name);
-}
-
-void
-RebMenus :: Bitmap :: UnCache(const char* const pCh_Name)
-{
- GLOBALASSERT( pCh_Name );
- Implementation :: UnCache(pCh_Name);
-}
-
-void
-RebMenus :: Bitmap :: EmptyCache(void)
-{
- Implementation :: EmptyCache();
-}
-void
-RebMenus :: Bitmap :: Blit_Transparent
-(
- const char* const pCh_Name,
- r2rect R2Rect_Clip,
- r2pos dstR2Pos
-)
-{
- GLOBALASSERT( pCh_Name );
- Implementation :: Blit_Transparent
- (
- pCh_Name,
- R2Rect_Clip,
- dstR2Pos
- );
-}
-
-r2size
-RebMenus :: Bitmap :: GetSize(const char* const pCh_Name)
-{
- GLOBALASSERT( pCh_Name );
-
- return Implementation :: GetSize(pCh_Name);
-}
-
-#endif
- // UseRebMenus
-
-
-
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/rebmenus.hpp b/3dc/avp/support/rebmenus.hpp
deleted file mode 100644
index 3b18509..0000000
--- a/3dc/avp/support/rebmenus.hpp
+++ /dev/null
@@ -1,981 +0,0 @@
-/*
-
- rebmenus.hpp
-
-*/
-
-#ifndef _rebmenus_hpp
-#define _rebmenus_hpp 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
-/* Version settings *****************************************************/
- #define UseRebMenus Yes
- // If this is set, then the new menus are compiled in, and take
- // effect in-game
- // If this is set to no, then the new menus don't compile in
-
- #define OverrideOldMenus Yes
- // If this is set, then the new menus also override the out-of-game
- // menus. Don't set this without setting UseRebMenus
-
- #define SupportTextprintBeforeGame No
- // however, this causes a problem in the second call
- // to InitialiseTextures(), but only outside the debugger,
- // so it's a real pain to debug
-
-/* Includes *************************************************************/
-#if UseRebMenus
- #ifdef __cplusplus
- #ifndef _ourbool
- #include "ourbool.h"
- #endif
-
- #if 0
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
- #endif
-
- #ifndef _command
- #include "command.hpp"
- #endif
-
- #ifndef _r2base
- #include "r2base.h"
- #endif
-
- #if 0
- // Expects an enum "FontIndex" for the font to be defined in PROJFONT.H
- #ifndef _projfont
- #include "projfont.h"
- #endif
- #endif
-
- #ifndef _expvar_hpp
- #include "expvar.hpp"
- #endif
-
- #ifndef _projmenu_hpp
- #include "projmenu.hpp"
- // Include project specific header.
- /*
- It is assumed that this project specific header will define
- the following:
-
- - an "enum PageID" enumeration of the various pages in the menus;
- they must range in value from 0 inclusive to NUM_PAGE_IDS exclusive
- (currently gaps are allowed in the range, but an array of pointers
- gets defined so don't be excessive)
-
- - a TextID typedef giving an enumeration of text string IDs from
- the language localisation table
-
- - functions:
- void Init(void)
- void UnInit(void)
- void Maintain(void)
- within scope ProjectSpecific (either namespace or public static in a class)
- inside namespace RebMenus. They can be empty, but typically
- you should construct your menu pages within them.
-
- - a scope (class or namespace) Fonts containing
- ( static )
- FontIndex RebMenus :: Fonts :: GetIndex(OurBool bSelected)
- to tell the text code which font to use for labels
- */
-
- #endif
- #endif
- /* __cplusplus */
-#endif
- // UseRebMenus
-
-
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-#if UseRebMenus
-#ifdef __cplusplus
- #define DUMMY_TEXTID ((TextID)0)
-
-namespace RebMenus
-{
- #if 0
- // perhaps has some kind of message passing hook:
- class Message
- {
- };
- // derived classes for keydown messages, mouse messages, etc
- // But how is it interrogated?
- // (you have two class hierarchies, with a single process fn)
- //
- // What class have I forgotten?
-
- // need a class with somd kind of hook for either processing
- // a messages, or passing it down the chain of responsibility
- // (a boolean return type to say whether it's been processed?)
-
- class MessageProcessor
- {
-
- };
-
- class Selectable : MessageProcessor //?????
- {
- };
- #endif
- enum Direction
- {
- D_Horiz,
- D_Vert
- };
-
- enum Alignment
- {
- Align_Min,
- // means "left-aligned" for V-composition, "top-aligned" for H-Composition
-
- Align_Centre,
- // means "centred about X" for V-composition, "centred about Y" for H-Composition
-
- Align_Max
- // means "right-aligned" for V-composition, "bottom-aligned" for H-Composition
-
- };
-
- enum NavigationOp
- {
- NavOp_Up = 0,
- NavOp_Down,
- NavOp_Left,
- NavOp_Right,
- NavOp_Home,
- NavOp_End,
- NavOp_Trigger,
- NavOp_Cancel,
-
- NUM_NAVIGATION_OPS
- };
-
- // Name of a bitmap, for referring to bitmaps in an appearance:
- class BitmapName
- {
- public:
- BitmapName
- (
- char* pCh_New
- ) : pCh_Val(pCh_New)
- {
- }
- BitmapName() : pCh_Val(NULL)
- {
- }
- const char* const Get(void) const
- {
- return pCh_Val;
- }
-
- private:
- const char* const pCh_Val;
- };
-
- // Name of an FMV sequence, for referring to FMV sequences in an appearance:
- class FMVName
- {
- public:
- FMVName
- (
- char* pCh_New
- ) : pCh_Val(pCh_New)
- {
- }
- FMVName() : pCh_Val(NULL)
- {
- }
- const char* const Get(void) const
- {
- return pCh_Val;
- }
-
- private:
- const char* const pCh_Val;
- };
-
- namespace Bitmap
- {
- void Precache(const char* const pCh_Name);
- void UnCache(const char* const pCh_Name);
- void EmptyCache(void);
-
- void Blit_Transparent
- (
- const char* const pCh_Name,
- r2rect R2Rect_Clip,
- r2pos dstR2Pos
- );
-
- r2size GetSize(const char* const pCh_Name);
- };
-
- // Menu-specific commands:
- class Command_JumpToPage : public Command
- {
- public:
- Command_JumpToPage
- (
- enum PageID thePage
- ) : Command(),
- thePage_Val(thePage)
- {
- }
- OurBool Execute(void);
-
- private:
- const enum PageID thePage_Val;
- };
-
- class Command_ReturnFromPage : public Command
- {
- public:
- OurBool Execute(void);
- };
-
- // Class for describing size requirements of things in the menus
- // Currently only support a "minimum size" idea
- class SizeInfo
- {
- public:
- SizeInfo
- (
- r2size minR2Size,
- int Column0_minW
- ) : minR2Size_Val(minR2Size),
- Column0_minW_Val(Column0_minW)
- {
- }
- r2size GetMin(void) const
- {
- return minR2Size_Val;
- }
- int GetColumn0_minW(void) const
- {
- return Column0_minW_Val;
- }
-
- SizeInfo Overlay
- (
- SizeInfo other
- );
-
- SizeInfo AddColumn
- (
- SizeInfo nextColumn
- );
-
- SizeInfo AddRow
- (
- SizeInfo nextRow
- );
-
- void Compose
- (
- const SizeInfo& other,
- enum Direction theD,
- enum Alignment theAl
- );
- private:
- r2size minR2Size_Val;
- int Column0_minW_Val;
-
- };
-
-
- class RenderContext
- {
- public:
- RenderContext
- (
- r2rect R2Rect_Clip_New,
- r2pos R2Pos_At_New,
- // top-left hotspot
- int Column0_W_New
- // width of 1st column
- ) : R2Rect_Clip_Val(R2Rect_Clip_New),
- R2Pos_At_Val(R2Pos_At_New),
- Column0_W_Val(Column0_W_New)
- {
- }
- r2rect ClipRect(void) const {return R2Rect_Clip_Val;}
- r2pos Pos(void) const {return R2Pos_At_Val;}
- int Column0_W(void) const {return Column0_W_Val;}
- r2pos Pos_Column1(void) const
- {
- return r2pos
- (
- R2Pos_At_Val . x + Column0_W_Val,
- R2Pos_At_Val . y
- );
- }
-
- RenderContext NextColumn(void) const
- {
- return RenderContext
- (
- R2Rect_Clip_Val,
- Pos_Column1(),
- 0
- );
- }
-
- private:
- r2rect R2Rect_Clip_Val;
- r2pos R2Pos_At_Val;
- int Column0_W_Val;
- };
-
- // 9/3/98 DHM: A "policy" pattern for what an item sould look like:
- // ("Design Patterns" would call it a "strategy", but since that word
- // is already overused in 3DC et al I prefer the alternate name "policy")
- class Appearance
- {
- public:
- // Use just a text label:
- Appearance
- (
- TextID ID_Label
- ) : bHasTextLabel(Yes),
- ID_Label_Val(ID_Label),
- bHasBitmap(No),
- bHasFMV(No)
- {
- }
-
- // Use just a bitmap:
- Appearance
- (
- BitmapName inBMapName
- ) : bHasTextLabel(No),
- ID_Label_Val(DUMMY_TEXTID),
- bHasBitmap(Yes),
- BMapN_Val(inBMapName),
- bHasFMV(No)
- {
- }
-
- // Don't have any appearance at all = invisible
- Appearance
- (
- ) : bHasTextLabel(No),
- ID_Label_Val(DUMMY_TEXTID),
- bHasBitmap(No),
- bHasFMV(No)
- {
- }
-
- // Other possible appearances might be:
- // - bitmaps,
- // - fmv sequences,
- // - combos of the above
- // etc
-
- void Diagnostic(void) const;
-
- // Methods relating to rendering:
- void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- SizeInfo GetSizeInfo(void) const;
-
- private:
- const OurBool bHasTextLabel;
- const TextID ID_Label_Val;
-
- const OurBool bHasBitmap;
- const BitmapName BMapN_Val;
-
- const OurBool bHasFMV;
- const FMVName FMVN_Val;
- };
-
- // An appearance with two states:
- class OnOffAppearance
- {
- public:
- // Constructors
- OnOffAppearance
- (
- Appearance App_On,
- Appearance App_Off
- ) : App_On_Val(App_On),
- App_Off_Val(App_Off)
- {
- // most general constructor: independent appearances, one for
- // "on", the other for "off"
- }
-
- OnOffAppearance
- (
- Appearance App_Shared
- ) : App_On_Val(App_Shared),
- App_Off_Val(App_Shared)
- {
- // easy way to give something the same appearance both on and off
- }
-
- OnOffAppearance
- (
- TextID ID_Label
- ) : App_On_Val(Appearance(ID_Label)),
- App_Off_Val(Appearance(ID_Label))
- {
- // easy way of setting up a text label
- }
-
- OnOffAppearance
- (
- ) : App_On_Val(Appearance()),
- App_Off_Val(Appearance())
- {
- // easy way to set up something as invisible both on and off
- }
-
-
- Appearance GetAppearance(OurBool bOn) const
- {
- return
- (
- bOn
- ?
- App_On_Val
- :
- App_Off_Val
- );
- }
-
- SizeInfo GetSizeInfo(void) const;
-
- private:
- Appearance App_On_Val;
- Appearance App_Off_Val;
- };
-
- class SelectionVariable
- {
- protected:
- SelectionVariable
- (
- BoundedExportVariable<int>* pBoundedExpVar
- // takes responsibility for deleting this
- ) : pBoundedExpVar_Val(pBoundedExpVar)
- {
- }
-
- public:
- virtual ~SelectionVariable()
- {
- delete pBoundedExpVar_Val;
- }
-
- virtual Appearance GetAppearance(OurBool bSelected) = 0;
-
- // Chain-of-responsibility onto the bounded export var:
- int Get(void) const
- {
- return pBoundedExpVar_Val -> Get();
- }
-
- int GetMin(void) const
- {
- return pBoundedExpVar_Val -> GetMin();
- }
- int GetMax(void) const
- {
- return pBoundedExpVar_Val -> GetMax();
- }
- int GetNxt(void) const
- {
- int CurrentVal = pBoundedExpVar_Val -> Get();
- if ( CurrentVal < pBoundedExpVar_Val -> GetMax() )
- {
- return ++CurrentVal;
- }
- else
- {
- return pBoundedExpVar_Val -> GetMin();
- }
- }
- int GetPrv(void) const
- {
- int CurrentVal = pBoundedExpVar_Val -> Get();
- if ( CurrentVal > pBoundedExpVar_Val -> GetMin() )
- {
- return --CurrentVal;
- }
- else
- {
- return pBoundedExpVar_Val -> GetMax();
- }
- }
- void Set(int NewVal)
- {
- pBoundedExpVar_Val -> Set(NewVal);
- }
-
- private:
- BoundedExportVariable<int>* pBoundedExpVar_Val;
- };
-
-
-
- // Class for a list of discrete selections with appearances and values:
- template <class T,int MAX_IN_LIST> class Selection
- {
- class Selectable
- {
- public:
- Selectable
- (
- Appearance theApp,
- T theValue
- ) : App_Val(theApp),
- T_Val(theValue)
- {
- }
- Appearance GetAppearance(void) const
- {
- return App_Val;
- }
- T GetValue(void) const
- {
- return T_Val;
- }
- private:
- const Appearance App_Val;
- const T T_Val;
- };
-
- class SelectionList
- {
- public:
- SelectionList
- (
- ) : NumInList(0)
- {
- }
-
- ~SelectionList();
-
- AddSelection
- (
- Selectable Sel_ToAdd
- )
- {
- if ( NumInList < MAX_IN_LIST )
- {
- theSel_A[NumInList++] = Sel_ToAdd;
- }
- }
- private:
- int NumInList;
- Selectable theSel_A[MAX_IN_LIST];
- };
- };
-
-
- class Item
- {
- public:
- OurBool bSelectable(void);
- // items can be temporarily or permanently unselectable
- // e.g. "greyed out"
-
- /////////////// PURE VIRTUAL FUNCTIONS ///////////////////////////////
- public:
- // Process various keypresses:
- virtual OurBool Navigate( enum NavigationOp aNavOp ) = 0;
- // return = was message processed
-
- virtual void Diagnostic(OurBool bSelected) const = 0;
-
- virtual void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const = 0;
-
- virtual SizeInfo GetSizeInfo(void) const = 0;
-
-
- public:
- void DiagnosticAppearance(OurBool bSelected) const;
-
- // Methods relating to rendering:
- void RenderAppearance
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const
- {
- theOnOffApp_Val . GetAppearance
- (
- bSelected
- ) . Render
- (
- theContext,
- bSelected
- );
- }
- SizeInfo AppearanceSizeInfo(void) const
- {
- return theOnOffApp_Val . GetSizeInfo();
- }
-
-
- public:
- virtual void Selected_Hook
- (
- enum NavigationOp // theNavOp
- )
- {
- // empty default implementation
- }
-
- protected:
- Item
- (
- OnOffAppearance theOnOffApp_New
- ) : theOnOffApp_Val(theOnOffApp_New)
- {
- // empty inline constructor; but protected so must use
- // a derived class.
- }
-
- virtual ~Item()
- {
- }
-
- private:
- OnOffAppearance theOnOffApp_Val;
- };
-
- // Proposed derived classes of Item:
- class Item_Unimplemented;
-
- class Item_Command;
- // contains a command; can contain a "goto menu page" command
-
- class Item_Selection;
-
- class Item_Slider;
-
- class Item_Toggle;
-
- class Item_KeyConfig_PageView;
-
- // A composition of items.
- // There will exist a selected item iff there are any items contained
- // in this composition
- class CompositeItem : public Item
- {
- public:
- CompositeItem
- (
- OnOffAppearance theOnOffApp_New,
- enum Direction theD,
- enum Alignment theAlignment_New
- ) : Item(theOnOffApp_New),
- theDir(theD),
- theAlignment_Val(theAlignment_New),
- NumItems(0)
- {
- // what value should SelectedItem have when there aren't any items?
- }
-
- // Combined factory/"add to list" methods:
- Item_Unimplemented* AddUnimplementedItem
- (
- OnOffAppearance theOnOffApp
- );
-
- Item_Command* AddNewCommandItem
- (
- OnOffAppearance theOnOffApp,
- Command* pCommand
- );
-
- Item_Command* AddNewJumpItem
- (
- OnOffAppearance theOnOffApp,
- enum PageID theDst
- );
-
- Item_Selection* AddNewSelectionItem
- (
- OnOffAppearance theOnOffApp,
- enum Direction initDir,
- SelectionVariable* pSelectionVar
- );
-
- Item_Slider* AddNewSliderItem
- (
- OnOffAppearance theOnOffApp,
- enum Direction initDir,
- BoundedExportVariable<int>* pBoundedExpVar
- );
-
- Item_Toggle* AddNewToggleItem
- (
- OnOffAppearance theOnOffApp_Label,
- enum Direction initDir,
- OnOffAppearance theOnOffApp_Choice,
- ExportVariable<OurBool>* pExpVar
- );
-
- CompositeItem* AddNewCompositeItem
- (
- OnOffAppearance theOnOffApp,
- enum Direction theD,
- enum Alignment theAlignment_New
- );
-
- Item* AddNewCancelItem
- (
- OnOffAppearance theOnOffApp
- );
-
- void AddNewItem_Special(Item* pItem);
-
- // Process various keypresses:
- OurBool Navigate( enum NavigationOp aNavOp );
- // return = was message processed
-
- virtual void Diagnostic(OurBool bSelected) const;
-
- Item* GetSelected(void) const;
- // will return NULL iff there are no items in the composition
-
- // Get index of next selectable
- #if 0
- // what if all disabled?
-
- // what if wraparound turned off?
-
- ItemIndex NxtSelectable(void) const;
- ItemIndex PrvSelectable(void) const;
- #endif
-
- // Methods relating to rendering:
- virtual void Render
- (
- const RenderContext& theContext,
- OurBool bSelected
- ) const;
-
- virtual SizeInfo GetSizeInfo(void) const;
-
-
- private:
- void AddToList
- (
- Item* pItem_ToAdd
- );
- static int ItemSpacing(void);
-
- // List of selectables:
- enum {MAX_ITEMS_PER_LIST = 20};
-
- int NumItems;
- Item* pItem_A[ MAX_ITEMS_PER_LIST ];
-
- #if 1
- int SelectedItem;
- #else
- // Selected item:
- IndexInRange theIIR;
- #endif
-
- // Direction:
- const enum Direction theDir;
-
- // Alignment:
- const enum Alignment theAlignment_Val;
-
- // selection list contains a list of selectables;
- // has a selected child.
-
- // Has an "enum direction":
- // if D_Horiz, interprets left/right as moving the selection
- // if D_Vert, interprets up/down as moving the selection
-
- // Considered doing it with two separate classes, but makes it nasty
- // to derive stuff off them
-
- };
-
-
- class Page : public CompositeItem
- {
- // This class maintains a static array
- // mapping of PageIDs to Page*s
- // There can be at most one Page of each ID; the class implements
- // a kind of array of singletons
- // (See "Design Patterns" Addison-Wesley 1994)
-
- // The precise classes derived from Page are project-specific. A project might
- // choose to derive a new class used by all of its pages, or have
- // a separate class for each page, or any combination in between.
-
- // An internal class for storing a history of menu pages visited:
- class MiniStack
- {
- // A small stack; when it gets full, the items
- // at the bottom are lost
- // Originally done as a template, but Jonathon told be to stop being too
- // clever for my own good...
-
- public:
- enum { NUM_PAGES_MEMORY = 16 };
-
- public:
- MiniStack() : NumItems(0)
- {
- }
-
- void Push(enum PageID in);
-
- OurBool Pop(enum PageID& out);
- // return value: was there anything?
-
- void Diagnostic(void);
-
- void Clear(void);
-
- private:
- int NumItems;
- enum PageID theA[ NUM_PAGES_MEMORY ];
- };
-
- protected:
- Page
- (
- Appearance theApp_New,
- enum Direction theD,
- enum Alignment theAlignment_New,
- PageID theID
- );
-
- ~Page();
-
- public:
- void Diagnostic(OurBool bSelected) const;
-
- static void SelectPage(enum PageID inID);
- static void SelectPage_ClearingStack(enum PageID inID);
- static void TryToReturn(void);
-
- static Page* Get(enum PageID inID);
- static Page* GetSelected(void);
-
- private:
- // Every page can have hook functions for entering/leaving the page
- // These are private since they're only to be called by the page selection
- // function
- // Default implementation is empty; specific pages can override this.
- virtual void Hook_EnteringPage(void)
- {
- }
- virtual void Hook_LeavingPage(void)
- {
- }
-
- private:
- static void Internal_SelectPage_NoPush( enum PageID inID );
- // Worker function to call hooks and actually change the page
- // Used by SelectPage() and TryToReturn()
- // Doesn't push current page onto page stack
-
-
- private:
-
- const PageID theID_Val;
- static Page* pPage[ NUM_PAGE_IDS ];
-
- static enum PageID SelectedPageID;
-
- static MiniStack thePageStack;
- };
-
-
- // What happens if you compose various levels of selection list?
- //
-
- // Is a menu page a type of selection list; if so, how does it respond
- // to cursor keys?
-
- //
-
- // now
-
- class Wraparound
- {
- public:
- static OurBool bEnabled(void)
- {
- return bEnabled_Val;
- }
-
- private:
- const static OurBool bEnabled_Val;
- };
-
- // Globals within RebMenus:
- void Init(void);
- void UnInit(void);
- void Maintain(void);
- void Render(void);
-
-
-}; // end of namespace RebMenus
-#endif // __cplusplus
-#endif // UseRebMenus
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
-
- extern void REBMENUS_ProjectSpecific_EndOfMainLoopHook(void);
-
-#ifdef __cplusplus
- };
-#endif
-
-/* End of the header ****************************************************/
-
-
-#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/3dc/avp/support/reflist.cpp b/3dc/avp/support/reflist.cpp
deleted file mode 100644
index 1757022..0000000
--- a/3dc/avp/support/reflist.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: reflist.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 28/1/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "reflist.hpp"
-
-/* Exported globals ************************************************/
-
- char const* reflist_fail_destructor = "Failure in RefList destructor\n";
diff --git a/3dc/avp/support/reflist.hpp b/3dc/avp/support/reflist.hpp
deleted file mode 100644
index cf91549..0000000
--- a/3dc/avp/support/reflist.hpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-
- REFLIST.HPP
-
- Created 27/1/98 by DHM:
- -----------------------
-
- Template for managing lists of pointers to reference-counted objects.
-
- The functions R_AddRef() and R_Release() must be defined for the type parameter.
-
- Uses the list template LIST_TEM.HPP
-
- The access functions return pointers to objects, or NULL for failure. The rule
- is that:
-
- Read()
- ------
- just returns a pointer; the caller should R_AddRef() only if they want to store the pointer
- somewhere (like the COM out-parameter rule; see p81 of "Inside COM")
-
- GetYour()
- ---------
- destructively reads the pointer from the list; ownership of the reference is transferred
- to the caller who _must_ call R_Release() at some subsequent point.
-
-*/
-
-#ifndef _reflist_hpp
-#define _reflist_hpp 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
- #ifndef list_template_hpp
- #include "list_tem.hpp"
- #endif
-
- #ifndef _refobj
- #include "refobj.hpp"
- #endif
-
-extern char const* reflist_fail_destructor;
-
-
-/* Type definitions *****************************************************/
-
-// nb templates cannot have C linkage
-template <class RC> class RefList
-{
-private:
- List<RC*> List_pRC;
-
-public:
- // {{{ Constructors:
- RefList() : List_pRC()
- {
- }
- // }}}
-
- // {{{ Destructor
- ~RefList()
- {
- EmptyYourself();
- }
- // }}}
-
- // {{{
- int NumEntries(void) const
- {
- return List_pRC . size();
- }
- // }}}
-
- // {{{ Inserting new members
- void AddToFront(RC& theRC)
- {
- theRC . R_AddRef();
-
- List_pRC . add_entry_start( &theRC );
- }
- void AddToEnd(RC& theRC)
- {
- theRC . R_AddRef();
-
- List_pRC . add_entry_end( &theRC );
- }
- // }}}
-
- // {{{ Accessing & removing existing members; see notes at top of header
- RC* ReadFirst(void) const
- {
- if (List_pRC . size() >0 )
- {
- return List_pRC . first_entry();
- }
- else
- {
- return NULL;
- }
- }
- RC* ReadFinal(void) const
- {
- if (List_pRC . size() >0 )
- {
- return List_pRC . last_entry();
- }
- else
- {
- return NULL;
- }
- }
- RC* GetYourFirst(void)
- {
- if (List_pRC . size() >0 )
- {
- RC* pReturn = List_pRC . first_entry();
-
- List_pRC . delete_first_entry();
- // note that a reference is still owned; ownership is transferred to the caller
-
- return pReturn;
- }
- else
- {
- return NULL;
- }
- }
- RC* GetYourFinal(void)
- {
- if (List_pRC . size() >0 )
- {
- RC* pReturn = List_pRC . last_entry();
-
- List_pRC . delete_last_entry();
- // note that a reference is still owned; ownership is transferred to the caller
-
- return pReturn;
- }
- else
- {
- return NULL;
- }
- }
- void EmptyYourself(void)
- {
- // Destroys the list, releasing all refs
- while ( List_pRC . size() > 0 )
- {
- RC* pRC = List_pRC . first_entry();
-
- List_pRC . delete_first_entry();
-
- #ifndef NDEBUG
- if ( !pRC )
- {
- fail( reflist_fail_destructor );
- }
- #endif
-
- pRC -> R_Release();
- }
- }
- // }}}
-
-
-}; // end of template <class RC> class RefList
-
-
-/* End of the header ****************************************************/
-
-
-#endif
diff --git a/3dc/avp/support/refobj.cpp b/3dc/avp/support/refobj.cpp
deleted file mode 100644
index e1c4181..0000000
--- a/3dc/avp/support/refobj.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: refobj.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 15/9/97
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "refobj.hpp"
-
- #if TrackReferenceCounted
- #include "dcontext.hpp"
-
- #ifndef list_template_hpp
- #include "list_tem.hpp"
- #endif
- #endif
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
- #if TrackReferenceCounted
- #define OutputRefCountLogOnExit Yes
-
-
- #if OutputRefCountLogOnExit
- #include "debuglog.hpp"
- #endif
-
-
- #endif
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
- char const* refobj_fail_addref = "Failure in R_AddRef()\n";
- char const* refobj_fail_release = "Failure in R_Release()\n";
- char const* refobj_fail_destructor = "Failure in Destructor()\n";
-
-/* Internal type definitions ***************************************/
-#if TrackReferenceCounted
-class RefCountObject_TrackData
-{
-public:
- enum transtype
- {
- tt_addref,
- tt_release
- };
-
-private:
- class ReferenceTransaction
- {
- public:
- void Dump( R_DumpContext& theContext ) const;
-
- private:
- char* Filename;
- int LineNum;
- enum transtype Type;
-
- protected:
- ReferenceTransaction(char* theFilename, int theLineNum, enum transtype theType) :
- Filename(theFilename),
- LineNum(theLineNum),
- Type(theType)
- {}
- };
-
- class Transaction_R_AddRef : public ReferenceTransaction
- {
- public:
- Transaction_R_AddRef(char* theFilename, int theLineNum) :
- ReferenceTransaction(theFilename, theLineNum, tt_addref)
- {}
- };
-
- class Transaction_R_Release : public ReferenceTransaction
- {
- public:
- Transaction_R_Release(char* theFilename, int theLineNum) :
- ReferenceTransaction(theFilename, theLineNum, tt_release)
- {}
- };
-
-public:
- static void DumpAll(R_DumpContext& theContext);
-
- RefCountObject_TrackData(RefCountObject *const pRCObj, char* theFilename, int theLineNum);
- ~RefCountObject_TrackData();
-
- void Track_R_AddRef(char* theFilename, int theLineNum);
- void Track_R_Release(char* theFilename, int theLineNum);
-
- void DumpTransactions( R_DumpContext& theContext ) const;
-
-private:
- RefCountObject *const pRCObj_Val;
- char* constructionFilename;
- int constructionLineNum;
- List<ReferenceTransaction*> List_pTransaction;
-
-private:
- /*
- Maintain various global stuff.
- This is all held together as a BSS object so that we can be sure that we call
- the log-on-exit in the destructor before destroying the records of what hasn't
- been fully released.
-
- We maintain a list of all reference counted objects, which the class RefCountObject
- has indirect access to.
-
- */
- class Globals
- {
- friend class RefCountObject_TrackData;
-
- private:
- List<RefCountObject*> List_pRCObj;
- #if OutputRefCountLogOnExit
- char* filename;
- #endif
- public:
- #if OutputRefCountLogOnExit
- Globals(char* theFilename) :
- filename(theFilename),
- #else
- Globals() :
- #endif
- List_pRCObj()
- {
- }
- ~Globals();
-
- };
-
- static Globals theGlobals;
-};
-
-
- static RefCountObject_TrackData :: Globals RefCountObject_TrackData :: theGlobals
- (
- #if OutputRefCountLogOnExit
- "REFDUMP.TXT"
- #endif
- );
-
- #if 0
- static List<RefCountObject*> RefCountObject_TrackData :: TheList :: List_pRCObj;
- #endif
-
-
-
-#endif
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-
-// class RefCountObject
-#if TrackReferenceCounted
-void RefCountObject :: Track_Construct(void)
-{
- GLOBALASSERT( pTrackData == NULL );
-
- pTrackData = new RefCountObject_TrackData(this,"unknown file",666);
-}
-
-void RefCountObject :: Track_R_AddRef(char* theFilename, int theLineNum)
-{
- GLOBALASSERT( pTrackData );
-
- pTrackData -> Track_R_AddRef(theFilename,theLineNum);
-}
-
-void RefCountObject :: Track_R_Release(char* theFilename, int theLineNum)
-{
- GLOBALASSERT( pTrackData );
-
- pTrackData -> Track_R_Release(theFilename,theLineNum);
-}
-
-void RefCountObject :: Track_Destroy(void)
-{
- GLOBALASSERT( pTrackData );
-
- delete pTrackData;
-}
-
-void RefCountObject :: ReferenceDump(R_DumpContext& theContext) const
-{
- GLOBALASSERT( pTrackData );
-
- DumpIDForReferenceDump(theContext);
-
- pTrackData -> DumpTransactions(theContext);
-}
-
-static void RefCountObject :: DumpAll(R_DumpContext& theContext)
-{
- RefCountObject_TrackData :: DumpAll(theContext);
-}
-#endif // TrackReferenceCounted
-/* Internal function definitions ***********************************/
-#if TrackReferenceCounted
-// class RefCountObject_TrackData
-// class RefCountObject_TrackData :: ReferenceTransaction
-// public:
-void RefCountObject_TrackData :: ReferenceTransaction :: Dump( R_DumpContext& theContext ) const
-{
- char* Action =
- (
- ( Type == tt_addref)
- ?
- "R_AddRef()"
- :
- "R_Release()"
- );
-
- theContext.dprintf("-- %s in file \"%s\" at line %i\n",Action,Filename,LineNum);
-}
-
-// public:
-static void RefCountObject_TrackData :: DumpAll(R_DumpContext& theContext)
-{
- theContext . dprintf
- (
- "RefCountObject::DumpAll(); num objects=%i\n",
- theGlobals . List_pRCObj . size()
- );
-
- for
- (
- CLIF<RefCountObject*> oi(&theGlobals . List_pRCObj);
- !oi . done();
- oi . next()
- )
- {
- GLOBALASSERT(oi());
- oi() -> ReferenceDump(theContext);
- }
-}
-RefCountObject_TrackData :: RefCountObject_TrackData(RefCountObject *const pRCObj,char* theFilename, int theLineNum) :
- pRCObj_Val(pRCObj),
- List_pTransaction(),
- constructionFilename(theFilename),
- constructionLineNum(theLineNum)
-{
- theGlobals . List_pRCObj . add_entry(pRCObj_Val);
-}
-
-RefCountObject_TrackData :: ~RefCountObject_TrackData()
-{
- while ( List_pTransaction . size() > 0)
- {
- List_pTransaction . delete_first_entry();
- }
-
- theGlobals . List_pRCObj . delete_entry(pRCObj_Val);
-
-}
-
-void RefCountObject_TrackData :: Track_R_AddRef(char* theFilename, int theLineNum)
-{
- List_pTransaction . add_entry_end
- (
- new Transaction_R_AddRef(theFilename,theLineNum)
- );
-}
-
-void RefCountObject_TrackData :: Track_R_Release(char* theFilename, int theLineNum)
-{
- List_pTransaction . add_entry_end
- (
- new Transaction_R_Release(theFilename,theLineNum)
- );
-}
-
-void RefCountObject_TrackData :: DumpTransactions( R_DumpContext& theContext) const
-{
- theContext . dprintf("-- Constructed in \"%s\" at line %i\n",constructionFilename,constructionLineNum);
- for
- (
- CLIF<ReferenceTransaction*> oi(&List_pTransaction);
- !oi . done();
- oi . next()
- )
- {
- oi() -> Dump(theContext);
- }
-}
-
-// private:
-
-#if OutputRefCountLogOnExit
-// We put one of these in the BSS segment so that its destructor
-// gets called at exit. The destructor writes all the info
-// to a log file
-// class Globals
-RefCountObject_TrackData :: Globals :: ~Globals()
-{
- LogFile theLogFile(filename);
- RefCountObject :: DumpAll(theLogFile);
-}
-#endif
-
-#endif // TrackReferenceCounted \ No newline at end of file
diff --git a/3dc/avp/support/refobj.hpp b/3dc/avp/support/refobj.hpp
deleted file mode 100644
index 9fad9b2..0000000
--- a/3dc/avp/support/refobj.hpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-
- refobj.hpp
-
- Created by DHM for Headhunter; copied into AVP
-
- Reference-counted base class to be used by e.g. strings
-
-*/
-
-#ifndef _refobj
-#define _refobj 1
-
-
- #ifndef __fail_h
- #include "fail.h"
- #endif
-
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-/* Version settings *****************************************************/
- #define TrackReferenceCounted No
- /*
- This is a debug option that has a fair amount of run-time
- cost.
-
- It maintains a list of all reference-counted objects, and
- data on when references were added or released.
-
- Data on a particular object can be sent to a log file;
- there is a function to do this for all that exist.
- */
-
-/* Macros ***************************************************************/
-
-#if TrackReferenceCounted
- #define R_AddRef() imp_R_AddRef(__FILE__,__LINE__)
- #define R_Release() imp_R_Release(__FILE__,__LINE__)
-#endif
-
-/* Imported globals *****************************************************/
-
- extern char const* refobj_fail_addref;
- extern char const* refobj_fail_release;
- extern char const* refobj_fail_destructor;
-
-
-/* Type definitions *****************************************************/
- class R_DumpContext; // fully declared in DCONTEXT.HPP
-
- class RefCountObject_TrackData; // fully declared within REFOBJ.CPP
-
- class RefCountObject
- {
- // {{{ Private data
- private:
- int RefCount;
-
- #if TrackReferenceCounted
- RefCountObject_TrackData* pTrackData;
- // done as a non-NULL pointer rather than a ref so as to hide
- // definition (avoiding compiler dependency)
- #endif
-
- // }}}
-
-
- // {{{ Private functions
- private:
- // Private fns for the tracking system are complex and defined in REFOBJ.CPP
- #if TrackReferenceCounted
- void Track_Construct(void);
- void Track_R_AddRef(char* theFilename, int theLineNum);
- void Track_R_Release(char* theFilename, int theLineNum);
- void Track_Destroy(void);
- #endif
- // }}}
-
- public:
- RefCountObject() :
- #if TrackReferenceCounted
- pTrackData(NULL),
- #endif
- RefCount(1)
- {
- #if TrackReferenceCounted
- Track_Construct();
- #endif
- }
-
- #if TrackReferenceCounted
- void imp_R_AddRef(char* theFilename, int theLineNum)
- {
- #ifndef NDEBUG
- if ( RefCount <= 0)
- {
- fail(refobj_fail_addref);
- }
- #endif
- RefCount++;
-
- Track_R_AddRef(theFilename,theLineNum);
- }
-
- void imp_R_Release(char* theFilename, int theLineNum)
- {
- #ifndef NDEBUG
- if ( RefCount <= 0)
- {
- fail(refobj_fail_release);
- }
- #endif
-
- Track_R_Release(theFilename,theLineNum);
-
- if ( (--RefCount) == 0 )
- {
- delete this;
- }
- }
- #else
- void R_AddRef(void)
- {
- #ifndef NDEBUG
- if ( RefCount <= 0)
- {
- fail(refobj_fail_addref);
- }
- #endif
- RefCount++;
- }
-
- void R_Release(void)
- {
- #ifndef NDEBUG
- if ( RefCount <= 0)
- {
- fail(refobj_fail_release);
- }
- #endif
-
- if ( (--RefCount) == 0 )
- {
- delete this;
- }
- }
- #endif
-
- #if debug
- int CheckRef() const
- {
- return RefCount;
- }
- // Handy way to examine reference count for debugging only
- #endif
-
- #if TrackReferenceCounted
- virtual void DumpIDForReferenceDump(R_DumpContext& theContext) const = 0;
- void ReferenceDump(R_DumpContext& theContext) const;
- static void DumpAll(R_DumpContext& theContext);
- #endif
-
- protected:
- // Destructors must be protected; only derived classes may use the
- // destructor and (we hope) only in the R_Release() method:
- virtual ~RefCountObject()
- {
- #ifndef NDEBUG
- if ( RefCount != 0 )
- {
- fail(refobj_fail_destructor);
- }
- #endif
-
- #if TrackReferenceCounted
- Track_Destroy();
- #endif
- }
- };
-
-
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/rentrntq.cpp b/3dc/avp/support/rentrntq.cpp
deleted file mode 100644
index b00464e..0000000
--- a/3dc/avp/support/rentrntq.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: rentrntq.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 21/11/97
- * (refer to comment in RENTRTQ.H from a description of what
- * this is for)
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "gadget.h"
-
-#if SupportWindows95
-
-#include "rentrntq.h"
-
- #if UseGadgets
- #include "iofocus.h"
- #include "hudgadg.hpp"
- #include "textin.hpp"
- #include "consbind.hpp"
- #endif
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
- #define MAX_Q_MESSAGES (256)
-
-#if 0
- #if 1
- #define METACHAR_CHANGEFOCUS '~'
- #else
- #define METACHAR_CHANGEFOCUS '\r'
- #endif
-
- #define METAKEY_CHANGEFOCUS_VK (0xdf)
- /*
- DHM 14/1/98:
- ------------
-
- I have been asked to make this key the
-
- "you know, the tilde key, the one in the top left of everyone's
- keyboards, like Quake does"
-
- However, I have yet to find a keyboard for which the tilde key is in the
- top left.
-
- I obtained the value (0xdf) by experiment on my keyboard. According to
- the Petzold book:
-
- "Although all keys cause keystroke messages, the table does not
- include any symbol keys (such as the key with the / and ? symbols).
- These keys have virtual key codes of 128 and above, and they are often
- defined differently for international keyboards. You can determine the
- values of these virtual key codes using the KEYLOOK program that is shown
- later in this chapter, but normally you should not process keystroke
- messages for these keys."
-
- What about DirectInput?
-
- */
-#endif
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
- enum QEntryCategory
- {
- QEntryCat_WM_CHAR,
- QEntryCat_WM_KEYDOWN,
-
- NUM_Q_ENTRY_CATS
- };
-
- struct Q_Entry
- {
- enum QEntryCategory QEntryCat;
-
- union
- {
- char Ch;
- // Valid for: QEntryCat_WM_CHAR
-
- WPARAM wParam;
- // Valid for: QEntryCat_WM_KEYDOWN
- } CatData;
- };
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
- static struct Q_Entry OurQ[MAX_Q_MESSAGES];
- static unsigned int NumQMessages = 0;
-
-/* Exported function definitions ***********************************/
-/* Functions callable within the Windows procedure */
-void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR
-(
- char Ch
-)
-{
- if ( NumQMessages < MAX_Q_MESSAGES )
- {
- OurQ[ NumQMessages ] . QEntryCat = QEntryCat_WM_CHAR;
- OurQ[ NumQMessages ] . CatData . Ch = Ch;
- NumQMessages++;
- }
- // otherwise ignore the message
- // since no decent error handling facilties/memory allocators
- // can safely be called at this stage
-}
-
-void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN
-(
- WPARAM wParam
-)
-{
- if ( NumQMessages < MAX_Q_MESSAGES )
- {
- OurQ[ NumQMessages ] . QEntryCat = QEntryCat_WM_KEYDOWN;
- OurQ[ NumQMessages ] . CatData . wParam = wParam;
- NumQMessages++;
- }
- // otherwise ignore the message
- // since no decent error handling facilties/memory allocators
- // can safely be called at this stage
-}
-
-
-/* Functions callable from the WinMain() body of code */
-void RE_ENTRANT_QUEUE_WinMain_FlushMessages(void)
-{
- // Process the messages:
- {
- #if UseGadgets
- // AVP/Win95-specific code
- if ( HUDGadget :: GetHUD() )
- {
- int i;
-
- for (i=0;i<NumQMessages;i++)
- {
- switch ( OurQ[ i ] . QEntryCat )
- {
- case QEntryCat_WM_CHAR:
- {
- char Ch = OurQ[ i ] . CatData . Ch;
-
- if
- (
- Ch != '`'
- // hack to ignore the grave key
- )
- {
- if ( IOFOCUS_AcceptTyping() )
- {
- HUDGadget :: GetHUD() -> CharTyped
- (
- Ch
- );
- }
- }
- #if 0
- textprint
- (
- "\n\n\nWM_CHAR message flushed; code=0x%x\n\n\n",
- Ch
- );
- #endif
- }
- break;
-
- case QEntryCat_WM_KEYDOWN:
- {
- if ( IOFOCUS_AcceptTyping() )
- {
- switch ( OurQ[i] . CatData . wParam )
- {
- default:
- // ignore most keys;
- break;
-
- case VK_BACK:
- HUDGadget :: GetHUD() -> Key_Backspace();
- break;
- case VK_END:
- HUDGadget :: GetHUD() -> Key_End();
- break;
- case VK_HOME:
- HUDGadget :: GetHUD() -> Key_Home();
- break;
- case VK_LEFT:
- HUDGadget :: GetHUD() -> Key_Left();
- break;
- case VK_UP:
- HUDGadget :: GetHUD() -> Key_Up();
- break;
- case VK_RIGHT:
- HUDGadget :: GetHUD() -> Key_Right();
- break;
- case VK_DOWN:
- HUDGadget :: GetHUD() -> Key_Down();
- break;
- case VK_INSERT:
- TextInputState :: ToggleTypingMode();
- break;
- case VK_DELETE:
- HUDGadget :: GetHUD() -> Key_Delete();
- break;
- case VK_TAB:
- HUDGadget :: GetHUD() -> Key_Tab();
- break;
- }
-
- }
- else
- {
- #if KeyBindingUses_WM_KEYDOWN
- // 6/4/98:
- // Pass the key to the console-binding code:
- KeyBinding::Process_WM_KEYDOWN
- (
- OurQ[i] . CatData . wParam
- );
- #endif
- }
- #if 0
- textprint
- (
- "\n\n\nWM_KEYDOWN message flushed; code=0x%x\n\n\n",
- OurQ[i] . CatData . wParam
- );
- #endif
-
- }
- break;
-
- }
- }
- }
- #endif
- }
-
- // Clear the messages (only place where a semaphore might be needed):
- NumQMessages = 0;
-}
-
-void RE_ENTRANT_QUEUE_WinMain_FlushMessagesWithoutProcessing(void)
-{
- NumQMessages = 0;
-}
-
-/* Internal function definitions ***********************************/
-
-
-
-
-
-#endif // SupportWindows95
diff --git a/3dc/avp/support/rentrntq.h b/3dc/avp/support/rentrntq.h
deleted file mode 100644
index 763cafb..0000000
--- a/3dc/avp/support/rentrntq.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-
- rentrntq.h
-
- Created 21/11/97 by DHM:
-
- "Support for a queue of messages (generated by/analagous to Windows messages)
- to avoid problems with re-entrancy".
-
- The problem being solved is that (in theory at least) the application's
- WinProc() procedure can be called at any point within any function in the Win32 API.
-
- This means that any code that the application's WinProc procedure
- calls (both directly or indirectly) must, in general, be re-entrant
-
- For example, textprint(), the memory allocators, etc. can't be guaranteed to work if
- called from WinProc() or something called by it. This is a mahor restriction on what
- you can call from WinProc.
-
- The idea of this code is to isolate the re-entrancy by buffering the
- messages, which can then be flushed somewhere "safe" within the main loop
- that doesn't need to be re-entrant.
-
- Functions within this header are labelled with either (i)"WinProc" or (ii)"WinMain"
- in their names to indicate whether (i)they should be called from the windows procedure
- or (ii) from within the WinMain function (or anything it calls i.e. the entire program
- and main loop _except_ for the windows procedure)
-*/
-
-#ifndef _rentrntq
-#define _rentrntq 1
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
- /* Functions callable within the Windows procedure */
- extern void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR
- (
- char Ch
- );
-
- extern void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN
- (
- WPARAM wParam
- );
-
- /* Functions callable from the WinMain() body of code */
- extern void RE_ENTRANT_QUEUE_WinMain_FlushMessages(void);
- extern void RE_ENTRANT_QUEUE_WinMain_FlushMessagesWithoutProcessing(void);
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/scstring.cpp b/3dc/avp/support/scstring.cpp
deleted file mode 100644
index 94f3b19..0000000
--- a/3dc/avp/support/scstring.cpp
+++ /dev/null
@@ -1,1973 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: string.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created ages ago
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "scstring.hpp"
-
-#if SupportHHStuff
- #include "hhfonts.h"
- #include "hhfile.h"
- #include "ifmisc.h"
- #include "holder.hpp"
- #include "mcstring.hpp"
-#else
- #include "strutil.h"
- #include "indexfnt.hpp"
-#endif
-
- #if TrackReferenceCounted
- #include "dcontext.hpp"
- #endif
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-#ifdef __WATCOMC__
-#pragma warning 139 5
-#pragma message("Disabled Warning W139")
-#endif
-
-
-/* Version settings ************************************************/
- #define LogStringTables No
-
-/* Constants *******************************************************/
- #define MAX_BYTES_IN_NUMERIC_STRING (100)
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- extern DISPLAYBLOCK *Player;
-
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
- /*static*/ SCString* SCString :: pFirst = NULL;
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
- #if SupportHHStuff
- static void strutil_Failure(Failure_Behaviour FailBehav);
- #endif
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class SCString
-// public:
-#if TrackReferenceCounted
-void SCString :: DumpIDForReferenceDump(R_DumpContext& theContext) const
-{
- theContext . dprintf("SCString \"%s\" refs remainining=%i\n",pProjCh_Val,CheckRef());
-}
-#endif
-
-ProjChar* SCString :: pProjCh(void) const
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjCh_Val );
- }
-
- /* CODE */
- {
- return pProjCh_Val;
- }
-}
-
-
-SCString :: SCString
-(
- const ProjChar* pProjCh_Init
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjCh_Init );
- }
-
- /* CODE */
- {
- AllocatedSize = (size_t) STRUTIL_SC_NumBytes
- (
- pProjCh_Init
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
-
- STRUTIL_SC_StrCpy
- (
- pProjCh_Val,
- pProjCh_Init
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- IndexedFont* pFont = IndexedFont :: GetFont( i );
-
- if ( pFont )
- {
- #if EnableSizeData
- R2Size[ i ] = pFont -> CalcSize
- (
- pProjCh_Val
- );
- #endif
- bCanRender[ i ] = pFont -> bCanRenderFully
- (
- pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- R2Size[ i ] = r2size(0,0);
- #endif
- bCanRender[ i ] = No;
- }
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
- }
-}
-
-SCString :: SCString
-(
- signed int Number
-)
-{
- // forms a new string object that describes the number passed
- // standard decimal representation
-
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- ProjChar pProjCh_Init[ MAX_BYTES_IN_NUMERIC_STRING ];
-
- sprintf
- (
- pProjCh_Init,
- "%i",
- (int)Number
- );
-
- #if 0
- LOCALISEME();
- #endif
-
- AllocatedSize = (size_t) STRUTIL_SC_NumBytes
- (
- pProjCh_Init
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
-
- STRUTIL_SC_StrCpy
- (
- pProjCh_Val,
- pProjCh_Init
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- IndexedFont* pFont = IndexedFont :: GetFont( i );
-
- if ( pFont )
- {
- #if EnableSizeData
- R2Size[ i ] = pFont -> CalcSize
- (
- pProjCh_Val
- );
- #endif
-
- bCanRender[ i ] = pFont -> bCanRenderFully
- (
- pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- R2Size[ i ] = r2size(0,0);
- #endif
- bCanRender[ i ] = No;
- }
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- }
-}
-
-SCString :: SCString
-(
- unsigned int Number
-)
-{
- // forms a new string object that describes the number passed
- // standard decimal representation
-
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- ProjChar pProjCh_Init[ MAX_BYTES_IN_NUMERIC_STRING ];
-
- sprintf
- (
- pProjCh_Init,
- "%u",
- Number
- );
-
- #if 0
- LOCALISEME();
- #endif
-
- AllocatedSize = (size_t) STRUTIL_SC_NumBytes
- (
- pProjCh_Init
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
-
- STRUTIL_SC_StrCpy
- (
- pProjCh_Val,
- pProjCh_Init
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- IndexedFont* pFont = IndexedFont :: GetFont( i );
-
- if ( pFont )
- {
- #if EnableSizeData
- R2Size[ i ] = pFont -> CalcSize
- (
- pProjCh_Val
- );
- #endif
-
- bCanRender[ i ] = pFont -> bCanRenderFully
- (
- pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- R2Size[ i ] = r2size(0,0);
- #endif
- bCanRender[ i ] = No;
- }
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- }
-}
-
-SCString :: SCString
-(
- float Number
-)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- ProjChar pProjCh_Init[ MAX_BYTES_IN_NUMERIC_STRING ];
-
- sprintf
- (
- pProjCh_Init,
- "%6f",
- Number
- );
-
- #if 0
- LOCALISEME();
- #endif
-
- AllocatedSize = (size_t) STRUTIL_SC_NumBytes
- (
- pProjCh_Init
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
-
- STRUTIL_SC_StrCpy
- (
- pProjCh_Val,
- pProjCh_Init
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- IndexedFont* pFont = IndexedFont :: GetFont( i );
-
- if ( pFont )
- {
- #if EnableSizeData
- R2Size[ i ] = pFont -> CalcSize
- (
- pProjCh_Val
- );
- #endif
-
- bCanRender[ i ] = pFont -> bCanRenderFully
- (
- pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- R2Size[ i ] = r2size(0,0);
- #endif
- bCanRender[ i ] = No;
- }
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- }
-}
-
-
-
-SCString :: SCString
-(
- ProjChar* pProjCh_Init,
- unsigned int Length
-)
-{
- // Forms a string of length at most Length (with 1 extra for NULL-terminator)
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjCh_Init );
- }
-
- /* CODE */
- {
- NumberOfCharacters = STRUTIL_SC_Strlen( pProjCh_Init );
- // doesn't include NULL terminator
-
- if ( NumberOfCharacters > Length )
- {
- NumberOfCharacters = Length;
- }
-
- AllocatedSize = (size_t) STRUTIL_SC_NumBytes
- (
- pProjCh_Init
- );
-
- {
- size_t TruncSize = sizeof(ProjChar) * (Length + 1);
-
- if (AllocatedSize > TruncSize )
- {
- AllocatedSize = TruncSize;
- }
- }
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
-
- STRUTIL_SC_SafeCopy
- (
- pProjCh_Val,
- (NumberOfCharacters+1),
-
- pProjCh_Init
- );
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- IndexedFont* pFont = IndexedFont :: GetFont( i );
-
- if ( pFont )
- {
- #if EnableSizeData
- R2Size[ i ] = pFont -> CalcSize
- (
- pProjCh_Val
- );
- #endif
-
- bCanRender[ i ] = pFont -> bCanRenderFully
- (
- pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- R2Size[ i ] = r2size(0,0);
- #endif
-
- bCanRender[ i ] = No;
- }
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- }
-}
-
-
-SCString :: SCString
-(
- SCString* pStringObj_0,
- SCString* pStringObj_1
-)
-{
- // forms a new string object by concatenating the strings in 0
- // and 1
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pStringObj_0 );
- GLOBALASSERT( pStringObj_1 );
- }
-
- /* CODE */
- {
- ProjChar* pProjCh_Init_0 = pStringObj_0 -> pProjCh();
- GLOBALASSERT( pProjCh_Init_0 );
-
- ProjChar* pProjCh_Init_1 = pStringObj_1 -> pProjCh();
- GLOBALASSERT( pProjCh_Init_1 );
-
- AllocatedSize = (size_t)
- (
- STRUTIL_SC_NumBytes
- (
- pProjCh_Init_0
- )
- +
- STRUTIL_SC_NumBytes
- (
- pProjCh_Init_1
- )
- - sizeof(ProjChar) // only one null terminator needed
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
-
- // this is always "owned" by the String
- STRUTIL_SC_FastCat
- (
- pProjCh_Val,
- pProjCh_Init_0,
- pProjCh_Init_1
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- #if EnableSizeData
- R2Size[ i ] = pStringObj_0 -> CalcSize( i );
- R2Size[ i ] . w += pStringObj_1 -> CalcSize( i ) . w;
- #endif
-
- bCanRender[ i ] =
- (
- pStringObj_0 -> bCanRenderFully( i )
- &&
- pStringObj_1 -> bCanRenderFully( i )
- );
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- }
-}
-
-
-SCString :: SCString
-(
- SCString* pStringObj_0,
- SCString* pStringObj_1,
- SCString* pStringObj_2
-)
-{
- // forms a new string object by concatenating the strings in 0, 1 and 2
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pStringObj_0 );
- GLOBALASSERT( pStringObj_1 );
- GLOBALASSERT( pStringObj_2 );
- }
-
- /* CODE */
- {
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- SCString* pStringObj_Intermediate = new SCString
- (
- pStringObj_1,
- pStringObj_2
- );
-
- {
-
- ProjChar* pProjCh_Init_0 = pStringObj_0 -> pProjCh();
- GLOBALASSERT( pProjCh_Init_0 );
-
- ProjChar* pProjCh_Intermediate = pStringObj_Intermediate -> pProjCh();
- GLOBALASSERT( pProjCh_Intermediate );
-
- AllocatedSize = (size_t)
- (
- STRUTIL_SC_NumBytes
- (
- pProjCh_Init_0
- )
- +
- STRUTIL_SC_NumBytes
- (
- pProjCh_Intermediate
- )
- - sizeof(ProjChar) // only one null terminator needed
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
- STRUTIL_SC_FastCat
- (
- pProjCh_Val,
- pProjCh_Init_0,
- pProjCh_Intermediate
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- #if EnableSizeData
- R2Size[ i ] = pStringObj_0 -> CalcSize( i );
- R2Size[ i ] . w +=
- (
- pStringObj_1 -> CalcSize( i ) . w
- +
- pStringObj_2 -> CalcSize( i ) . w
- );
- #endif
-
- bCanRender[ i ] =
- (
- pStringObj_0 -> bCanRenderFully( i )
- &&
- pStringObj_1 -> bCanRenderFully( i )
- &&
- pStringObj_2 -> bCanRenderFully( i )
- );
- }
- }
- #endif
- }
-
-
- pStringObj_Intermediate -> R_Release();
-
- }
-}
-
-SCString :: SCString
-(
- SCString* pStringObj_0,
- SCString* pStringObj_1,
- SCString* pStringObj_2,
- SCString* pStringObj_3
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pStringObj_0 );
- GLOBALASSERT( pStringObj_1 );
- GLOBALASSERT( pStringObj_2 );
- GLOBALASSERT( pStringObj_3 );
- }
-
- /* CODE */
- {
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- SCString* pStringObj_Intermediate = new SCString
- (
- pStringObj_1,
- pStringObj_2,
- pStringObj_3
- );
-
- {
-
- ProjChar* pProjCh_Init_0 = pStringObj_0 -> pProjCh();
- GLOBALASSERT( pProjCh_Init_0 );
-
- ProjChar* pProjCh_Intermediate = pStringObj_Intermediate -> pProjCh();
- GLOBALASSERT( pProjCh_Intermediate );
-
- AllocatedSize = (size_t)
- (
- STRUTIL_SC_NumBytes
- (
- pProjCh_Init_0
- )
- +
- STRUTIL_SC_NumBytes
- (
- pProjCh_Intermediate
- )
- - sizeof(ProjChar) // only one null terminator needed
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
- STRUTIL_SC_FastCat
- (
- pProjCh_Val,
- pProjCh_Init_0,
- pProjCh_Intermediate
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- #if EnableSizeData
- R2Size[ i ] = pStringObj_0 -> CalcSize( i );
- R2Size[ i ] . w +=
- (
- pStringObj_1 -> CalcSize( i ) . w
- +
- pStringObj_2 -> CalcSize( i ) . w
- +
- pStringObj_3 -> CalcSize( i ) . w
- );
- #endif
-
- bCanRender[ i ] =
- (
- pStringObj_0 -> bCanRenderFully( i )
- &&
- pStringObj_1 -> bCanRenderFully( i )
- &&
- pStringObj_2 -> bCanRenderFully( i )
- &&
- pStringObj_3 -> bCanRenderFully( i )
- );
- }
- }
- #endif
- }
-
-
- pStringObj_Intermediate -> R_Release();
-
- }
-}
-
-
-SCString :: SCString
-(
- SCString* pStringObj_0,
- SCString* pStringObj_1,
- SCString* pStringObj_2,
- SCString* pStringObj_3,
- SCString* pStringObj_4
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pStringObj_0 );
- GLOBALASSERT( pStringObj_1 );
- GLOBALASSERT( pStringObj_2 );
- GLOBALASSERT( pStringObj_3 );
- GLOBALASSERT( pStringObj_4 );
- }
-
- /* CODE */
- {
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
-
- SCString* pStringObj_Intermediate = new SCString
- (
- pStringObj_1,
- pStringObj_2,
- pStringObj_3,
- pStringObj_4
- );
-
- {
-
- ProjChar* pProjCh_Init_0 = pStringObj_0 -> pProjCh();
- GLOBALASSERT( pProjCh_Init_0 );
-
- ProjChar* pProjCh_Intermediate = pStringObj_Intermediate -> pProjCh();
- GLOBALASSERT( pProjCh_Intermediate );
-
- AllocatedSize = (size_t)
- (
- STRUTIL_SC_NumBytes
- (
- pProjCh_Init_0
- )
- +
- STRUTIL_SC_NumBytes
- (
- pProjCh_Intermediate
- )
- - sizeof(ProjChar) // only one null terminator needed
- );
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
- // this is always "owned" by the String
- STRUTIL_SC_FastCat
- (
- pProjCh_Val,
- pProjCh_Init_0,
- pProjCh_Intermediate
- );
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- #if EnableSizeData
- R2Size[ i ] = pStringObj_0 -> CalcSize( i );
- R2Size[ i ] . w +=
- (
- pStringObj_1 -> CalcSize( i ) . w
- +
- pStringObj_2 -> CalcSize( i ) . w
- +
- pStringObj_3 -> CalcSize( i ) . w
- +
- pStringObj_4 -> CalcSize( i ) . w
- );
- #endif
-
- bCanRender[ i ] =
- (
- pStringObj_0 -> bCanRenderFully( i )
- &&
- pStringObj_1 -> bCanRenderFully( i )
- &&
- pStringObj_2 -> bCanRenderFully( i )
- &&
- pStringObj_3 -> bCanRenderFully( i )
- &&
- pStringObj_4 -> bCanRenderFully( i )
- );
- }
- }
- #endif
- }
-
-
- pStringObj_Intermediate -> R_Release();
-
- }
-}
-
-
-SCString :: SCString
-(
- List<ProjChar> List_ProjChar
-)
-{
- {
- AllocatedSize = (size_t) (List_ProjChar . size() + 1) * sizeof(ProjChar);
-
- pProjCh_Val = new ProjChar[ AllocatedSize ];
- GLOBALASSERT( pProjCh_Val );
-
- #if 1
- {
- ProjChar* pDst = pProjCh_Val;
-
- for
- (
- LIF<ProjChar> oi(&(List_ProjChar));
- !oi.done();
- oi.next()
- )
- {
- *(pDst++) = oi();
- }
-
- // Write terminator:
- *pDst = 0;
- }
- #else
- STRUTIL_SC_StrCpy
- (
- pProjCh_Val,
- pProjCh_Init
- );
- #endif
-
- NumberOfCharacters = ( AllocatedSize / sizeof(ProjChar ) ) - 1;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- {
- FDIBMAP FDIBMap_Temp;
-
- HHFONTS_GetSizeOfSingleLine
- (
- &FDIBMap_Temp,
-
- pProjCh_Val,
- pStandardFont
- );
-
- WidthGivenStandardFont = FDIBMap_Temp . Width;
- // width in pixels, to save constant recalc
- }
- #else
- {
- FontIndex i = IndexedFonts_MAX_NUMBER_OF_FONTS;
-
- while ( i>0 )
- {
- i = (FontIndex)(i-1);
-
- IndexedFont* pFont = IndexedFont :: GetFont( i );
-
- if ( pFont )
- {
- #if EnableSizeData
- R2Size[ i ] = pFont -> CalcSize
- (
- pProjCh_Val
- );
- #endif
- bCanRender[ i ] = pFont -> bCanRenderFully
- (
- pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- R2Size[ i ] = r2size(0,0);
- #endif
- bCanRender[ i ] = No;
- }
- }
- }
- #endif
-
- // Insert at head of list:
- {
- if ( pFirst )
- {
- pFirst -> pPrv = this;
- }
-
- pNxt = pFirst;
- pPrv = NULL;
-
- pFirst = this;
- }
- }
-
-}
-
-
-#if SupportHHStuff
-void SCString :: GetSizeOfSingleLineGivenStandardFont
-(
- FDIBMAP* pFDIBMap_Out
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pFDIBMap_Out );
- }
-
- /* CODE */
- {
- pFDIBMap_Out -> Width = WidthGivenStandardFont;
-
- pFDIBMap_Out -> Height = HHFONTS_GetMaxHeight
- (
- pStandardFont
- );
- }
-}
-
-FDIBMAP SCString :: GetSizeOfSingleLineGivenStandardFont(void)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- FDIBMAP FDIBMap_Temp;
-
- FDIBMap_Temp . Width = WidthGivenStandardFont;
-
- FDIBMap_Temp . Height = HHFONTS_GetMaxHeight
- (
- pStandardFont
- );
-
- return FDIBMap_Temp;
- }
-}
-
-int SCString :: GetWidthOfSingleLineGivenStandardFont(void)
-{
- return WidthGivenStandardFont;
-}
-
-FDIQUAD SCString :: MinFDIQuadForSCStringAtPos
-(
- FDIPOS FDIPos
-)
-{
- FDIQUAD FDIQuad_Temp = FDIQuad
- (
- FDIPos . LeftX,
- FDIPos . TopY,
- WidthGivenStandardFont,
- HHFONTS_GetMaxHeight
- (
- pStandardFont
- )
- );
-
- return FDIQuad_Temp;
-}
-#endif
-
-/*static*/ void SCString :: UpdateAfterFontChange( FontIndex I_Font_Changed )
-{
- // called by the font code whenever fonts are loaded/unloaded
-
- /* PRECONDITION */
- {
- GLOBALASSERT( I_Font_Changed < IndexedFonts_MAX_NUMBER_OF_FONTS );
- }
-
- /* CODE */
- {
- IndexedFont* pFont = IndexedFont :: GetFont( I_Font_Changed );
-
- SCString* pSCString = pFirst;
-
- while ( pSCString )
- {
- if ( pFont )
- {
- #if EnableSizeData
- pSCString -> R2Size[ I_Font_Changed ] = pFont -> CalcSize
- (
- pSCString -> pProjCh_Val
- );
- #endif
-
- pSCString -> bCanRender[ I_Font_Changed ] = pFont -> bCanRenderFully
- (
- pSCString -> pProjCh_Val
- );
- }
- else
- {
- #if EnableSizeData
- pSCString -> R2Size[ I_Font_Changed ] = r2size(0,0);
- #endif
-
- pSCString -> bCanRender[ I_Font_Changed ] = No;
- }
-
- pSCString = pSCString -> pNxt;
- }
- }
-}
-
-/*static*/ List<SCString*> SCString :: Parse
-(
- ProjChar* pProjChar_Start
-)
-{
- // takes a string and builds a list of new SCStrings, in which
- // each string in the list consists of non-whitespace characters from
- // the input, and the whitespace is used to separate individual
- // strings
-
- // I call the strings "words"
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjChar_Start );
- }
-
- /* CODE */
- {
- List<SCString*> List_Return;
-
- ProjChar* pProjChar_Iterate = pProjChar_Start;
- int NumCharsNonWhitespace = 0;
-
- while
- (
- *pProjChar_Iterate
- )
- {
- if
- (
- *pProjChar_Iterate == ' '
- )
- {
- // Whitespace:
- if ( NumCharsNonWhitespace > 0 )
- {
- // End of a word; add the string to the list:
- List_Return . add_entry
- (
- new SCString
- (
- pProjChar_Start,
- NumCharsNonWhitespace
- )
- );
- NumCharsNonWhitespace = 0;
- }
- else
- {
- // Already processing a block of whitespace; do nothing
- }
- }
- else
- {
- // Non-whitespace:
- if ( NumCharsNonWhitespace > 0 )
- {
- // In the middle of a word:
- }
- else
- {
- // Start of a word:
- pProjChar_Start = pProjChar_Iterate;
- }
-
- NumCharsNonWhitespace++;
-
- }
-
- pProjChar_Iterate++;
- }
-
- // End of the string; flush any remaining whitespace:
- if ( NumCharsNonWhitespace > 0 )
- {
- List_Return . add_entry
- (
- new SCString
- (
- pProjChar_Start,
- NumCharsNonWhitespace
- )
- );
- }
-
- return List_Return;
- }
-}
-
-
-//private:
-SCString :: ~SCString()
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjCh_Val );
- }
-
- /* CODE */
- {
- delete[] pProjCh_Val;
-
- // Remove from list:
- {
- if ( pFirst == this )
- {
- pFirst = pNxt;
- }
- else
- {
- pPrv -> pNxt = pNxt;
- }
-
- if (pNxt)
- {
- pNxt -> pPrv = pPrv;
- }
- }
-
- }
-}
-
-#if SupportHHStuff
-HHStringTable* STRUTIL_LoadStringTable(char* Filename,Failure_Behaviour FailBehav)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(Filename);
- }
- /* CODE */
- {
- /* Allocate memory for a table of pointers to strings in memory */
- HHStringTable* pHHST= (HHStringTable*)AllocateMem
- (
- sizeof(HHStringTable)
- );
-
- if (!pHHST)
- {
- /* Out of memory */
-
- return 0;
- }
- else
- {
-
- /* Load the file into a buffer in memory */
- OurByteBuffer ByteBuf;
- OurByte* pTextBuffer;
-
- {
- /* clear the pointers in the new string table */
- int i = MAX_ENTRIES_PER_STRING_TABLE;
- while (i>0)
- {
- i--;
-
- pHHST -> pStringObj[i] = NULL;
- }
-
- }
-
- HHFILE_LoadLogicalFile
- (
- Filename,
- FailBehav,
- &ByteBuf
- );
-
- pTextBuffer=ByteBuf.pbData;
-
- if (!pTextBuffer)
- {
- /* Error loading file */
- return 0;
- }
- else
- {
- /* Build table of string pointers in the buffer */
-
- #define START_OF_COMMENT_TC ('#')
- #define END_OF_COMMENT_TC (0x0D)
- #define SKIP_TC (0x0A)
-
- /*
- Scan through loaded buffer, finding strings, making copies with NULL termination,
- until you reach the end (can be signified by EOF or by two successive # characters
- without intermediate end-of-comment chars)
-
- When done, free up loaded buffer.
- */
-
- OurByte* pbExtract=pTextBuffer;
- unsigned int CountChars=0;
- OurBool StillGoing=Yes;
-
- OurBool FoundStartChar=No;
- OurBool FoundEndChar=No;
- ProjChar* pChStart=NULL;
- unsigned int CountSinceEndChar=0;
- unsigned int SkipChars=0;
-
- pHHST->NumEntries_Val=0;
-
- while
- (
- (CountChars<(ByteBuf.NumBytes))
- &&
- (StillGoing)
- )
- {
- ProjChar TChar=(ProjChar)*pbExtract;
-
- switch (TChar)
- {
- case SKIP_TC:
- /* Skip this char */
- {
- SkipChars++;
- }
- break;
-
- case START_OF_COMMENT_TC:
- if (FoundStartChar)
- {
- /* Two successive StartOf.. TChars without a EndOf... are a termination sequence */
- StillGoing=No;
- }
- else
- {
- /* It is the start of a comment */
- FoundStartChar=Yes;
- }
- break;
- case END_OF_COMMENT_TC:
- if (FoundEndChar)
- {
- /* This is the terminating character of a string; copy it up */
- LOCALASSERT(pChStart);
-
- /* copy it up here...*/
- #if LimitedStringLengths
- LOCALASSERT(CountSinceEndChar<MAX_STRING_LENGTH);
- #endif
-
- {
- ProjChar* NewString=(ProjChar*)AllocateMem((CountSinceEndChar+1)*sizeof(ProjChar));
-
- if (!NewString)
- {
- /* Out of memory... */
- strutil_Failure(FailBehav);
-
- }
- else
- {
- /* Copy up chars, except for SKIP_TC... */
- ProjChar* pSrc=pChStart;
- ProjChar* pDst=NewString;
-
- int i;
- for (i=0;i<(CountSinceEndChar+SkipChars);i++)
- {
- ProjChar ChSrc=*(pSrc++);
-
- if (ChSrc!=SKIP_TC)
- {
- *(pDst++)=ChSrc;
- }
- }
-
- STRUTIL_SC_WriteTerminator(pDst);
-
- GLOBALASSERT(pHHST->NumEntries() < MAX_ENTRIES_PER_STRING_TABLE);
-
- #if 1
- pHHST->pStringObj[ (pHHST->NumEntries_Val++) ] = new SCString
- (
- NewString
- ); // you get an automatic reference when you construct it.
-
- DeallocateMem( NewString );
-
- #else
- pHHST->pEntry[(pHHST->NumEntries_Val++)]=NewString;
- #endif
-
-
- }
- }
-
- FoundEndChar=No;
- FoundStartChar=No;
- CountSinceEndChar=0;
- SkipChars=0;
- pChStart=NULL;
- }
- else
- {
- if (FoundStartChar)
- {
- /* Then this signifies the end of a comment and the start of the string */
- FoundEndChar=Yes;
- CountSinceEndChar=0;
- SkipChars=0;
-
- /* Start extracting string from next character onwards...*/
- pChStart=(pbExtract+1);
- }
- /* else it is padding; ignore */
-
- }
-
- break;
- default:
- /* It is a normal character...*/
- if (FoundEndChar)
- {
- CountSinceEndChar++;
- }
-
- break;
- }
-
- /* On to next character */
- pbExtract++;
- CountChars++;
- }
-
-
- DeallocateMem(pTextBuffer);
-
- #if (debug && LogStringTables )
- {
- int i;
- char Temp[200];
-
- sprintf(Temp,"Loaded string table:\"%s\"",Filename);
- DAVELOG(Temp);
-
- sprintf(Temp,"Number of strings=%i",pHHST->NumEntries);
- DAVELOG(Temp);
-
- for (i=0;i<pHHST->NumEntries();i++)
- {
- GLOBALASSERT(pHHST->pStringObj[i]);
-
- if
- (
- STRUTIL_SC_Strlen
- (
- pHHST -> pStringObj[i] -> pProjCh()
- ) < 100
- )
- {
- sprintf
- (
- Temp,
- "Entry %3i=\"%s\"",
- i,
- pHHST -> pStringObj[i] -> pProjCh()
- );
- DAVELOG(Temp);
- }
- else
- {
- DAVELOG("String too long to log");
- }
- }
- sprintf(Temp,"End of string table:\"%s\"",Filename);
- DAVELOG(Temp);
- }
- #endif
-
- // Clear the lazy evaluation table:
- {
- MCSCString** ppMCStringObj_Clear = &(pHHST -> pMCStringObj[ 0 ][ 0 ]);
-
- for ( int i=pHHST->NumEntries(); i>0; i--)
- {
- for ( int j = NUM_BASE_COLOURS; j > 0; j-- )
- {
- *(ppMCStringObj_Clear++) = NULL;
- }
- }
- }
-
- /* Return a pointer to this table */
- return pHHST;
- }
- }
- }
-}
-
-void STRUTIL_UnloadStringTable(HHStringTable* pHHST)
-/* This function DOES deallocate the passed structure */
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pHHST);
- }
- /* CODE */
- {
- /* Kill off strings in table */
- int i;
-
- for (i=0;i<pHHST->NumEntries();i++)
- {
- #if 1
- LOCALASSERT( pHHST->pStringObj[i] );
- pHHST -> pStringObj[i] -> R_Release();
- #else
- LOCALASSERT(pHHST->pEntry[i]);
- DeallocateMem(pHHST->pEntry[i]);
- #endif
- }
-
- // R_Release any refs in the lazy evaluation table:
- {
- for (i=0;i<pHHST->NumEntries();i++)
- {
- for ( int j=0; j< NUM_BASE_COLOURS; j++ )
- {
- if ( pHHST -> pMCStringObj[i][j] )
- {
- pHHST -> pMCStringObj[ i ][ j ] -> R_Release();
- }
- }
- }
- }
-
- /* Kill off table of pointers */
- DeallocateMem(pHHST);
- }
-}
-
-ProjChar* STRUTIL_SC_GetString(HHStringTable* pHHST,unsigned int StrNum)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pHHST);
- GLOBALASSERT(StrNum<pHHST->NumEntries());
- GLOBALASSERT(StrNum< MAX_ENTRIES_PER_STRING_TABLE);
- }
- /* CODE */
- {
- GLOBALASSERT( pHHST -> pStringObj[StrNum] );
- GLOBALASSERT( pHHST -> pStringObj[StrNum] -> pProjCh() );
-
- return pHHST -> pStringObj[StrNum] -> pProjCh();
- }
-}
-
-unsigned int STRUTIL_GetNumEntries
-(
- HHStringTable* pHHST
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pHHST);
- }
- /* CODE */
- {
- unsigned int ReturnVal = pHHST -> NumEntries();
- GLOBALASSERT( ReturnVal <= MAX_ENTRIES_PER_STRING_TABLE);
-
- return ReturnVal;
- }
-}
-
-SCString* STRUTIL_GetSCString
-(
- HHStringTable* pHHST,
- unsigned int StrNum
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pHHST);
- GLOBALASSERT(StrNum<pHHST->NumEntries());
- GLOBALASSERT(StrNum< MAX_ENTRIES_PER_STRING_TABLE);
- }
- /* CODE */
- {
- GLOBALASSERT( pHHST -> pStringObj[StrNum] );
- GLOBALASSERT
- (
- pHHST -> pStringObj[StrNum] -> CheckRef()
- >
- 0
- );
- // check that the reference count is above zero
- // otherwise some code has messed up the reference
- // count and the string will have been deallocated...
-
- pHHST -> pStringObj[StrNum] -> R_AddRef();
-
- return pHHST -> pStringObj[StrNum];
- }
-}
-
-SCString* hhstringtablestruct :: GetSCString
-(
- unsigned int StrNum
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(StrNum< NumEntries() );
- GLOBALASSERT(StrNum< MAX_ENTRIES_PER_STRING_TABLE);
- }
-
- /* CODE */
- {
- GLOBALASSERT( pStringObj[StrNum] );
- GLOBALASSERT
- (
- pStringObj[StrNum] -> CheckRef()
- >
- 0
- );
- // check that the reference count is above zero
- // otherwise some code has messed up the reference
- // count and the string will have been deallocated...
-
- pStringObj[StrNum] -> R_AddRef();
-
- return pStringObj[StrNum];
- }
-}
-
-MCSCString* hhstringtablestruct :: GetMCSCString
-(
- unsigned int StrNum,
- LogicalColour LogCol
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(StrNum< NumEntries() );
- GLOBALASSERT(StrNum< MAX_ENTRIES_PER_STRING_TABLE);
- }
-
- /* CODE */
- {
- // Lazily evaluate:
- if
- (
- NULL == pMCStringObj[ StrNum ][ LogCol ]
- )
- {
- // no updating of reference count of SCString
- // due to direct access to the array
- pMCStringObj[ StrNum ][ LogCol ] = new MCSCString
- (
- pStringObj[StrNum],
- LogCol
- );
- }
-
- GLOBALASSERT( pMCStringObj[ StrNum ][ LogCol ] );
-
- pMCStringObj[ StrNum ][ LogCol ] -> R_AddRef();
-
- return pMCStringObj[ StrNum ][ LogCol ];
- }
-}
-
-
-
-
-
-#if debug
-void STRUTIL_Diagnostics(void)
-{
- /* CODE */
- {
- #if 0
- int i;
-
- for (i=0;i<pHHST_UserInterface->NumEntries;i++)
- {
- GLOBALASSERT(strlen(pHHST_UserInterface->pEntry[0])<90);
- textprint("String %i = \"%s\"\n",i,pHHST_UserInterface->pEntry[i]);
- }
- #endif
- }
-
- #if 0
- {
- int i;
-
- for
- textprint("%50s",pHHST_UserInterface->pEntry[0]);
- }
- #endif
-}
-#endif
-
-/* Internal function definitions ***********************************/
-static void strutil_Failure(Failure_Behaviour FailBehav)
-{
- /* unwritten */
-
- return;
-}
-#endif // SupportHHStuff
-
diff --git a/3dc/avp/support/scstring.hpp b/3dc/avp/support/scstring.hpp
deleted file mode 100644
index 257cfdc..0000000
--- a/3dc/avp/support/scstring.hpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
-
- scstring.hpp
-
-*/
-
-#ifndef _scstring
-#define _scstring 1
-
- #define SupportHHStuff No
-
- #ifndef _refobj
- #include "refobj.hpp"
- #endif
-
- #ifndef _ourbool
- #include "ourbool.h"
- #endif
-
- #if SupportHHStuff
- #ifndef HHSTRING
- #include "hhstring.h"
- #endif
-
- #ifndef FDIPUB_INCLUDED
- #include "fdipub.h"
- #endif
- #else
- #ifndef _projtext
- #include "projtext.h"
- #endif
-
- #ifndef _projfont
- #include "projfont.h"
- #endif
-
- #ifndef _r2base
- #include "r2base.h"
- #endif
-
- #endif
-
- #ifndef list_template_hpp
- #include "list_tem.hpp"
- #endif
-
- #define EnableSizeData Yes
-
- class SCString : public RefCountObject
- {
- public:
- ProjChar* pProjCh(void) const;
-
- SCString
- (
- const ProjChar* pProjCh_Init
- ); // you get an automatic reference when you construct it.
-
- SCString
- (
- signed int Number
- );
-
- SCString
- (
- unsigned int Number
- );
- // forms a new string object that describes the number passed
- // standard decimal representation
-
- SCString
- (
- float Number
- );
- // the string is to a standard number of decimal places
-
-
- SCString
- (
- ProjChar* pProjCh_Init,
- unsigned int Length
- );
- // Forms a string of length at most Length (with 1 extra for NULL-terminator)
-
- SCString
- (
- SCString* pStringObj_0,
- SCString* pStringObj_1
- );
- // forms a new string object by concatenating the strings in 0
- // and 1
-
- SCString
- (
- SCString* pStringObj_0,
- SCString* pStringObj_1,
- SCString* pStringObj_2
- );
- // forms a new string object by concatenating the strings in 0, 1 and 2
-
- SCString
- (
- SCString* pStringObj_0,
- SCString* pStringObj_1,
- SCString* pStringObj_2,
- SCString* pStringObj_3
- );
- // forms a new string object by concatenating the strings;
- // implementation is _slow_
-
- SCString
- (
- SCString* pStringObj_0,
- SCString* pStringObj_1,
- SCString* pStringObj_2,
- SCString* pStringObj_3,
- SCString* pStringObj_4
- );
- // forms a new string object by concatenating the strings;
- // implementation is _slow_
-
- SCString
- (
- List<ProjChar> List_ProjChar
- );
-
- #if SupportHHStuff
- void GetSizeOfSingleLineGivenStandardFont
- (
- FDIBMAP* pFDIBMap_Out
- );
- FDIBMAP GetSizeOfSingleLineGivenStandardFont(void);
- int GetWidthOfSingleLineGivenStandardFont(void);
-
- FDIQUAD MinFDIQuadForSCStringAtPos
- (
- FDIPOS FDIPos
- );
- #else
- r2size CalcSize
- (
- FontIndex I_Font
- );
- // Size for this string drawn on a single line in the specified font
- // Behaviour is not fully defined when unprintable characters occur in the string
-
- OurBool bCanRenderFully( FontIndex I_Font );
- // can this string be fully rendered by the font (not all fonts support
- // all characters) ?
-
- static void UpdateAfterFontChange( FontIndex I_Font_Changed );
- // called by the font code whenever fonts are loaded/unloaded
- #endif
-
- unsigned int GetNumChars(void);
-
- void ProcessAnyCheatCodes(void);
-
- void SendToScreen(void);
- // adds this as a new on-screen message
-
- static List<SCString*> Parse
- (
- ProjChar* pProjChar_In
- );
- // takes a string and builds a list of new SCStrings, in which
- // each string in the list consists of non-whitespace characters from
- // the input, and the whitespace is used to separate individual
- // strings
-
- #if TrackReferenceCounted
- void DumpIDForReferenceDump(R_DumpContext& theContext) const;
- #endif
-
- private:
- ~SCString();
- // private destructor; only called when reference count hits zero
-
- ProjChar* pProjCh_Val;
- // this is always "owned" by the String execpt when
- // fAllocFailure is set
-
- int NumberOfCharacters;
- // doesn't include NULL terminator
-
- #if SupportHHStuff
- int WidthGivenStandardFont;
- // width in pixels, to save constant recalc
- #else
- #if EnableSizeData
- r2size R2Size[ IndexedFonts_MAX_NUMBER_OF_FONTS ];
- #endif
-
- OurBool bCanRender[ IndexedFonts_MAX_NUMBER_OF_FONTS ];
- #endif
-
- size_t AllocatedSize;
- // this includes the NULL terminator
-
- // Maintain an intrusive doubly-linked list
- // so that you can find all the strings when a font is loaded/unloaded
- // and hence update their data
- // Strings are added to the front of the list upon construction
- SCString* pNxt;
- SCString* pPrv;
- static SCString* pFirst;
- }; // Naming: "StringObj"
-
- // Inline methods:
- #if !SupportHHStuff
- #if EnableSizeData
- inline r2size SCString::CalcSize
- (
- FontIndex I_Font
- )
- {
- return R2Size[ I_Font ];
- }
- #endif
-
- inline OurBool SCString::bCanRenderFully( FontIndex I_Font )
- {
- return bCanRender[ I_Font ];
- }
- #endif // !SupportHHStuff
-
- inline unsigned int SCString::GetNumChars(void)
- {
- return NumberOfCharacters;
- }
-
- #if SupportHHStuff
- extern SCString* HHSTRING_GetSCString
- (
- HHStringTable* pHHST,
- unsigned int StrNum
- );
- // The result is guaranteed to be non-NULL if you pick a valid
- // StrNum.
-
- // Remember to call R_AddRef() if you use the result
- // NO LONGER THE CASE!!!!
- #endif
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
-
-
diff --git a/3dc/avp/support/strtab.cpp b/3dc/avp/support/strtab.cpp
deleted file mode 100644
index 74a367d..0000000
--- a/3dc/avp/support/strtab.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: strtab.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 12 Nov 97
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "strtab.hpp"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-#if OnlyOneStringTable
- /*static*/ SCString* StringTable :: pSCString[ MAX_NO_OF_TEXTSTRINGS ];
- /*static*/ unsigned int StringTable :: NumStrings = 0;
-#endif
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class StringTable
-// public:
-/*STRINGTABLE_DECL_SPECIFIER*/ SCString& StringTable :: GetSCString
-(
- enum TEXTSTRING_ID stringID
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( stringID < MAX_NO_OF_TEXTSTRINGS );
- GLOBALASSERT( pSCString[ stringID ] );
- }
-
- /* CODE */
- {
- pSCString[ stringID ] -> R_AddRef();
- return *( pSCString[ stringID ] );
- }
-}
-
-
-/*STRINGTABLE_DECL_SPECIFIER*/ void StringTable :: Add( ProjChar* pProjChar )
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( NumStrings < MAX_NO_OF_TEXTSTRINGS );
- GLOBALASSERT( pSCString[ NumStrings ] == 0 );
- }
-
- /* CODE */
- {
- pSCString[ NumStrings++ ] = new SCString( pProjChar );
- }
-}
-
-#if OnlyOneStringTable
-/*static*/ void StringTable :: Unload(void)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- while ( NumStrings )
- {
- pSCString[ --NumStrings ] -> R_Release();
- }
- }
-}
-#else
-StringTable :: StringTable()
-{
- NumStrings = 0;
-}
-
-StringTable :: ~StringTable()
-{
- while ( NumStrings )
- {
- pSCString[ --NumStrings ] -> R_Release();
- }
-}
-#endif
-
-
-// private:
-
-// C-callable functions:
-#if OnlyOneStringTable
-extern void AddToTable( ProjChar* pProjChar )
-{
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjChar );
- }
-
- /* CODE */
- {
- StringTable :: Add( pProjChar );
- }
-}
-
-extern void UnloadTable(void)
-{
- /* PRECONDITION */
- {
- }
-
- /* CODE */
- {
- StringTable :: Unload();
- }
-}
-#endif
-
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/strtab.hpp b/3dc/avp/support/strtab.hpp
deleted file mode 100644
index da4bd6d..0000000
--- a/3dc/avp/support/strtab.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-
- strtab.hpp
-
-*/
-
-#ifndef _strtab
-#define _strtab 1
-
- #ifndef _projtext
- #include "projtext.h"
- #endif
-
- #ifndef _langenum_h_
- #include "langenum.h"
- #endif
-
- #ifdef __cplusplus
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
- #define OnlyOneStringTable Yes
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
- #if OnlyOneStringTable
- #define STRINGTABLE_DECL_SPECIFIER static
- #else
- #define STRINGTABLE_DECL_SPECIFIER
- #endif
-
-/* Type definitions *****************************************************/
- #ifdef __cplusplus
- class StringTable
- {
- public:
- STRINGTABLE_DECL_SPECIFIER SCString& GetSCString
- (
- enum TEXTSTRING_ID stringID
- );
-
- STRINGTABLE_DECL_SPECIFIER void Add( ProjChar* pProjChar );
-
- #if OnlyOneStringTable
- static void Unload(void);
- #else
- StringTable();
- ~StringTable();
- #endif
-
- private:
- STRINGTABLE_DECL_SPECIFIER unsigned int NumStrings;
- STRINGTABLE_DECL_SPECIFIER SCString* pSCString[ MAX_NO_OF_TEXTSTRINGS ];
- };
- #endif // __cplusplus
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
- #if OnlyOneStringTable
- extern void AddToTable( ProjChar* pProjChar );
- extern void UnloadTable(void);
- #endif
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/strutil.c b/3dc/avp/support/strutil.c
deleted file mode 100644
index 8175a2e..0000000
--- a/3dc/avp/support/strutil.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
-
- STRUTIL.C
-
- Created 13/11/97 by David Malcolm from Headhunter code: more carefully specified
- versions of the C string library functions, to act on ProjChars
- rather than chars
-
-*/
-
-#include "3dc.h"
-
-#include "strutil.h"
-
-#if 0
-#include "hhfile.h"
-
-#include "hhcolour.h"
-
-#include "daveserr.h"
-
-#include "inouttxt.h"
-#include "menutxt.h"
-
-#include "davelog.h"
-#endif
-
-#define UseLocalAssert Yes
-#include "ourasert.h"
-
-
-
-/* VERSION DEFINES */
-#define LogStringTables No
-
-#define MAX_ENTRIES_PER_STRING_TABLE (200)
-#define LimitedStringLengths Yes
-#if LimitedStringLengths
-#define MAX_STRING_LENGTH (30000)
-#endif
-
-/* TYPE DEFINITIONS */
-#if 0
-static HHMCTC HHMCTS_Terminator={'\0',LogCol_OpaqueBlack};
-#endif
-
-/* EXPORTED GLOBALS */
-
-#if 0
-HHStringTable* pHHST_UserInterface = NULL;
-HHStringTable* pHHST_MenuText = NULL;
-
-HHMCTC* HHMCTS_Blank=&HHMCTS_Terminator;
-#endif
-
-/* EXPORTED FUNCTION PROTOTYPES */
-#if 0
-void STRUTIL_Init(void)
-{
- pHHST_UserInterface=STRUTIL_LoadStringTable("hh/testdata/inout.txt",OnFailure_ExitSystem);
-
- LOCALASSERT(pHHST_UserInterface);
- /*
- If error loading text file containing the error message text strings,
- there is no real way to generate an error message...
- */
- LOCALASSERT
- (
- STRUTIL_GetNumEntries
- (
- pHHST_UserInterface
- )
- ==
- NUM_IN_OUT_TXT_MESSAGES
- );
-
- /* If we reach here, user interface messages have been loaded Ok... */
-
-
- pHHST_MenuText = STRUTIL_LoadStringTable
- (
- "hh/testdata/menu.txt",
- OnFailure_ExitSystem
- );
- LOCALASSERT( pHHST_MenuText );
- LOCALASSERT
- (
- STRUTIL_GetNumEntries
- (
- pHHST_MenuText
- )
- ==
- NUM_MENU_TXT_MESSAGES
- );
-
-}
-
-void STRUTIL_Destroy(void)
-{
- LOCALASSERT(pHHST_UserInterface);
-
- STRUTIL_UnloadStringTable(pHHST_UserInterface);
-
- LOCALASSERT(pHHST_MenuText);
-
- STRUTIL_UnloadStringTable(pHHST_MenuText);
-
-}
-#endif
-
-void STRUTIL_SC_WriteTerminator(ProjChar* pProjCh)
-{
- /* Supplied as a function in case we switch to double-byte character sets */
-
- *pProjCh='\0';
-
-}
-
-#if 0
-void STRUTIL_MC_WriteTerminator
-(
- HHMCTC* pHHMCTC
-)
-{
- GLOBALASSERT(pHHMCTC);
- /* Supplied as a function in case we switch to double-byte character sets */
-
- pHHMCTC->Char='\0';
-}
-#endif
-
-
-/* Ansi to HHTS conversion ********************************************/
-OurBool STRUTIL_ANSI_To_ProjChar
-(
- ProjChar* pProjCh_Out,
- unsigned int MaxSize, /* includes NULL-terminator; truncates after this */
-
- LPTSTR lptszANSI_In
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pProjCh_Out);
- GLOBALASSERT(lptszANSI_In);
- }
-
- /* CODE */
- {
- /* For the moment: */
- return STRUTIL_SC_SafeCopy
- (
- pProjCh_Out,
- MaxSize,
-
- lptszANSI_In
- );
- }
-}
-
-OurBool STRUTIL_ProjChar_To_ANSI
-(
- LPTSTR lptszANSI_Out,
- unsigned int MaxSize, /* includes NULL-terminator; truncates after this */
-
-ProjChar* pProjCh_In
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(lptszANSI_Out);
- GLOBALASSERT(pProjCh_In);
- }
-
- /* CODE */
- {
- /* For the moment: */
- return STRUTIL_SC_SafeCopy
- (
- lptszANSI_Out,
- MaxSize,
-
- pProjCh_In
- );
- }
-}
-
-unsigned int STRUTIL_SC_Strlen
-(
- const ProjChar* String
-)
-{
- GLOBALASSERT(String);
-
- return strlen(String);
-}
-
-#if 0
-unsigned int STRUTIL_MC_Strlen
-(
- HHMCTC* MCString
-)
-{
- unsigned int Count=0;
-
- while (MCString->Char!='\0')
- {
- MCString++;
- Count++;
- }
- return Count;
-}
-#endif
-
-
-ProjChar* STRUTIL_SC_StrCpy
-(
- ProjChar* pProjCh_Dst,
- const ProjChar* pProjCh_Src
-)
-{
- GLOBALASSERT(pProjCh_Dst);
- GLOBALASSERT(pProjCh_Src);
-
- return (strcpy(pProjCh_Dst,pProjCh_Src));
-}
-
-void STRUTIL_SC_FastCat
-(
- ProjChar* pProjCh_Dst,
- const ProjChar* pProjCh_Src_0,
- const ProjChar* pProjCh_Src_1
-)
-{
- /* This function assumes the destination area is large enough;
- it copies Src0 followed by Src1 to the dest area.
- */
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pProjCh_Dst );
- GLOBALASSERT( pProjCh_Src_0 );
- GLOBALASSERT( pProjCh_Src_1 );
- }
-
- /* CODE */
- {
- while ( *pProjCh_Src_0 )
- {
- *( pProjCh_Dst++ ) = *( pProjCh_Src_0++ );
- }
- while ( *pProjCh_Src_1 )
- {
- *( pProjCh_Dst++ ) = *( pProjCh_Src_1++ );
- }
-
- /* Write terminator */
- *pProjCh_Dst = 0;
- }
-}
-
-
-OurBool STRUTIL_SC_Strequal
-(
- const ProjChar* String1,
- const ProjChar* String2
-)
-{
-#if 0
- DAVELOG("Comparing strings");
- DAVELOG(String1);
- DAVELOG(String2);
-#endif
-
- while
- (
- (*String1!='\0')
- &&
- (*String2!='\0')
- )
- {
- if
- (
- (*String1)
- !=
- (*String2)
- )
- {
- return No;
- }
- String1++;
- String2++;
- }
-
- return
- (
- (*String1)
- ==
- (*String2)
- );
-}
-
-OurBool STRUTIL_SC_Strequal_Insensitive
-(
- const ProjChar* String1,
- const ProjChar* String2
-)
-{
-
- while
- (
- (*String1!='\0')
- &&
- (*String2!='\0')
- )
- {
- if
- (
- (tolower(*String1))
- !=
- (tolower(*String2))
- )
- {
- return No;
- }
- String1++;
- String2++;
- }
-
- return
- (
- (tolower(*String1))
- ==
- (tolower(*String2))
- );
-}
-
-
-#if 0
-void STRUTIL_MC_MakeMCTS
-(
- HHMCTC* DestString,
- ProjChar* InputString,
- LogicalColour LogCol
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(DestString);
- GLOBALASSERT(InputString);
- GLOBALASSERT(LogCol<NUM_BASE_COLOURS);
- }
-
- /* CODE */
- {
-
- while (*InputString)
- {
- DestString->Char=*InputString;
- DestString->LogCol=LogCol;
-
- InputString++;
- DestString++;
- }
-
- STRUTIL_MC_WriteTerminator(DestString);
- }
-}
-#endif
-
-void STRUTIL_SC_SafeCat
-(
- ProjChar* pProjCh_Dst,
- unsigned int MaxSize,
-
- const ProjChar* pProjCh_Add
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pProjCh_Dst);
- GLOBALASSERT(pProjCh_Add);
- GLOBALASSERT(MaxSize>0);
- }
-
- /* CODE */
- {
- unsigned int MaxNonTerminatingCharsToUse = (MaxSize - 1);
-
- while
- (
- (*pProjCh_Dst)
- &&
- (MaxNonTerminatingCharsToUse>0)
- )
- {
- pProjCh_Dst++;
- MaxNonTerminatingCharsToUse--;
- }
-
- while
- (
- (*pProjCh_Add)
- &&
- (MaxNonTerminatingCharsToUse>0)
- )
- {
- *pProjCh_Dst = *pProjCh_Add;
-
- pProjCh_Add++;
- pProjCh_Dst++;
-
- MaxNonTerminatingCharsToUse--;
-
- STRUTIL_SC_WriteTerminator(pProjCh_Dst);
- }
- }
-}
-
-size_t STRUTIL_SC_NumBytes
-(
- const ProjChar* String
-)
-{
- return
- (
- sizeof(ProjChar)
- *
- (STRUTIL_SC_Strlen(String)+1)
- );
-}
-
-#if 0
-size_t STRUTIL_MC_NumBytes(HHMCTC* MCString)
-{
- return STRUTIL_MC_LengthToNumBytes
- (
- STRUTIL_MC_Strlen(MCString)
- );
-}
-
-size_t STRUTIL_MC_NumBytesFromSC
-(
- ProjChar* pProjCh
-)
-{
- return STRUTIL_MC_LengthToNumBytes
- (
- STRUTIL_SC_Strlen(pProjCh)
- );
-}
-
-size_t STRUTIL_MC_LengthToNumBytes(unsigned int Length)
-{
- return
- (
- sizeof(HHMCTC)
- *
- (Length+1)
- );
-}
-
-
-void STRUTIL_MC_CatHHTSOntoMCTS
-(
- HHMCTC* DestString,
- ProjChar* InputString,
- LogicalColour LogCol
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(DestString);
- GLOBALASSERT(InputString);
- GLOBALASSERT(LogCol<NUM_BASE_COLOURS);
- }
-
- /* CODE */
- {
- while (DestString->Char)
- {
- DestString++;
- }
-
- while (*InputString)
- {
- DestString->Char=*InputString;
- DestString->LogCol=LogCol;
-
- InputString++;
- DestString++;
-
- STRUTIL_MC_WriteTerminator(DestString);
- }
- }
-}
-
-void STRUTIL_MC_SafeMakeMCTS
-(
- HHMCTC* DestString,
- unsigned int MaxSize,
-
- ProjChar* InputString,
- LogicalColour LogCol
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(DestString);
- GLOBALASSERT(InputString);
- GLOBALASSERT(LogCol<NUM_BASE_COLOURS);
- GLOBALASSERT(MaxSize>0);
- }
-
- /* CODE */
- {
- unsigned int MaxNonTerminatingCharsToUse = (MaxSize - 1);
-
- while
- (
- (*InputString)
- &&
- (MaxNonTerminatingCharsToUse > 0)
- )
- {
- DestString->Char=*InputString;
- DestString->LogCol=LogCol;
-
- InputString++;
- DestString++;
- MaxNonTerminatingCharsToUse--;
- }
-
- STRUTIL_MC_WriteTerminator(DestString);
- }
-}
-
-void STRUTIL_MC_SafeCatHHTSOntoMCTS
-(
- HHMCTC* DestString,
- unsigned int MaxSize,
-
- ProjChar* AddString,
- LogicalColour LogCol
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(DestString);
- GLOBALASSERT(AddString);
- GLOBALASSERT(LogCol<NUM_BASE_COLOURS);
- GLOBALASSERT(MaxSize>0);
- }
-
- /* CODE */
- {
- unsigned int MaxNonTerminatingCharsToUse = (MaxSize - 1);
-
- while
- (
- (DestString->Char)
- &&
- (MaxNonTerminatingCharsToUse>0)
- )
- {
- DestString++;
- MaxNonTerminatingCharsToUse--;
- }
-
- while
- (
- (*AddString)
- &&
- (MaxNonTerminatingCharsToUse>0)
- )
- {
- DestString->Char=*AddString;
- DestString->LogCol=LogCol;
-
- AddString++;
- DestString++;
-
- MaxNonTerminatingCharsToUse--;
-
- STRUTIL_MC_WriteTerminator(DestString);
- }
- }
-}
-
-
-OurBool fValidHHMCTS(HHMCTC* MCString)
-{
- GLOBALASSERT(MCString);
-
- {
- unsigned int CharCount=0;
-
- while
- (
- (MCString->Char!='\0')
-#if LimitedStringLengths
- &&
- (CharCount<MAX_STRING_LENGTH)
-#endif
- )
- {
- if (MCString->LogCol>=NUM_BASE_COLOURS)
- {
- DAVELOG("Invalid colour in MC String");
- return No;
- }
- MCString++;
- }
-
- #if LimitedStringLengths
- {
- if (CharCount>=MAX_STRING_LENGTH)
- {
- DAVELOG("MC String too long...");
- return No;
- }
- else
- {
- return Yes;
- }
- }
- #else
- {
- return Yes;
- }
- #endif
-
- }
-}
-
-HHMCTC STRUTIL_SC_To_MC
-(
- ProjChar Char,
- LogicalColour LogCol
-)
-{
- HHMCTC ReturnVal;
-
- ReturnVal. Char = Char;
- ReturnVal. LogCol = LogCol;
-
- return ReturnVal;
-}
-#endif
-
-OurBool STRUTIL_SC_SafeCopy
-(
- ProjChar* pProjCh_Dst,
- unsigned int MaxSize,
-
- const ProjChar* pProjCh_Src
-)
-{
- GLOBALASSERT(pProjCh_Dst);
- GLOBALASSERT(MaxSize > 0);
- GLOBALASSERT(pProjCh_Src);
-
- {
- unsigned int MaxNonTerminatingCharsToCopy = (MaxSize - 1);
-
- while
- (
- (MaxNonTerminatingCharsToCopy > 0 )
- &&
- (*pProjCh_Src != 0)
- )
- {
- MaxNonTerminatingCharsToCopy--;
- *(pProjCh_Dst++) = *(pProjCh_Src++);
- }
-
- STRUTIL_SC_WriteTerminator(pProjCh_Dst);
-
- return ( STRUTIL_SC_fIsTerminator(pProjCh_Src) );
- }
-
-}
-
-#if 0
-OurBool STRUTIL_MC_SafeCopy
-(
- HHMCTC* pHHMCTC_Dst,
- unsigned int MaxSize,
-
- HHMCTC* pHHMCTC_Src
-
-)
-{
- /* PRECONDITION */
- {
- GLOBALASSERT(pHHMCTC_Dst);
- GLOBALASSERT(MaxSize > 0);
- GLOBALASSERT(pHHMCTC_Src);
- }
-
- /* CODE */
- {
- #if 1
- HHMCTC* pHHMCTC_StoredDst = pHHMCTC_Dst;
- #endif
-
- {
- unsigned int MaxNonTerminatingCharsToCopy = (MaxSize - 1);
-
- while
- (
- (MaxNonTerminatingCharsToCopy > 0 )
- &&
- (!STRUTIL_MC_fIsTerminator(pHHMCTC_Src))
- )
- {
- MaxNonTerminatingCharsToCopy--;
- *(pHHMCTC_Dst++) = *(pHHMCTC_Src++);
- }
-
- STRUTIL_MC_WriteTerminator(pHHMCTC_Dst);
-
- #if 0
- {
- char temp[256];
- sprintf
- (
- temp,
- "STRUTIL_MC_SafeCopy maxsize %i",
- MaxSize
- );
- DAVELOG(temp);
-
- {
- HHMCTC* pHHMCTC = pHHMCTC_StoredDst;
- char* pCh_Out = &temp[0];
- while ( pHHMCTC -> Char != '\0' )
- {
- *(pCh_Out++) = ( *(pHHMCTC++) ).Char;
- }
- *pCh_Out = '\0';
- }
- DAVELOG(temp);
- }
- #endif
-
- return ( STRUTIL_MC_fIsTerminator(pHHMCTC_Src) );
-
- }
- }
-
-}
-#endif
-
-OurBool STRUTIL_SC_fIsTerminator
-(
- const ProjChar* pProjCh
-)
-{
- GLOBALASSERT(pProjCh);
- return (*pProjCh == '\0');
-}
-
-#if 0
-OurBool STRUTIL_MC_fIsTerminator(HHMCTC* pHHMCTC)
-{
- GLOBALASSERT(pHHMCTC);
- return ((pHHMCTC->Char) == '\0');
-}
-
-
-HHMCTC* STRUTIL_MC_StrCpy
-(
- HHMCTC* pHHMCTC_Dst,
- HHMCTC* pHHMCTC_Src
-)
-{
- GLOBALASSERT(pHHMCTC_Dst);
- GLOBALASSERT(pHHMCTC_Src);
-
- while
- (
- pHHMCTC_Src->Char != '\0'
- )
- {
- *(pHHMCTC_Dst++) = *(pHHMCTC_Src++);
- }
- pHHMCTC_Dst->Char = '\0';
-}
-
-HHMCTC* STRUTIL_MC_FastCat
-(
- HHMCTC* pHHMCTC_Dst,
- HHMCTC* pHHMCTC_Src_0,
- HHMCTC* pHHMCTC_Src_1
-)
-{
- /* This function assumes the destination area is large enough;
- it copies Src0 followed by Src1 to the dest area.
- */
-
- /* PRECONDITION */
- {
- GLOBALASSERT( pHHMCTC_Dst );
- GLOBALASSERT( pHHMCTC_Src_0 );
- GLOBALASSERT( pHHMCTC_Src_1 );
- }
-
- /* CODE */
- {
- while
- (
- (!STRUTIL_MC_fIsTerminator(pHHMCTC_Src_0))
- )
- {
- *(pHHMCTC_Dst++) = *(pHHMCTC_Src_0++);
- }
-
- while
- (
- (!STRUTIL_MC_fIsTerminator(pHHMCTC_Src_1))
- )
- {
- *(pHHMCTC_Dst++) = *(pHHMCTC_Src_1++);
- }
-
- STRUTIL_MC_WriteTerminator(pHHMCTC_Dst);
-
- return pHHMCTC_Dst;
- }
-}
-
-
-#endif
diff --git a/3dc/avp/support/strutil.h b/3dc/avp/support/strutil.h
deleted file mode 100644
index 0659dca..0000000
--- a/3dc/avp/support/strutil.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-
- strutil.h
-
- Created 13/11/97 by David Malcolm: more carefully specified
- versions of the C string library functions, to act on ProjChars
- rather than chars
-
-*/
-
-#ifndef _strutil
-#define _strutil 1
-
- #ifndef _projtext
- #include "projtext.h"
- #endif
-
- #ifndef _ourbool
- #include "ourbool.h"
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
- /* String manipulation **********************************************/
- extern void STRUTIL_SC_WriteTerminator
- (
- ProjChar* pProjCh
- );
-
- extern OurBool STRUTIL_SC_fIsTerminator
- (
- const ProjChar* pProjCh
- );
-
- /* Ansi to HHTS conversion ********************************************/
- /* Return value = Yes iff no truncation occurred i.e. the whole string was copied */
-
- #if 0
- extern OurBool STRUTIL_ProjChar_To_ANSI
- (
- LPTSTR lptszANSI_Out,
- unsigned int MaxSize, /* includes NULL-terminator; truncates after this */
-
- ProjChar* pProjCh_In
- );
-
- extern OurBool STRUTIL_ANSI_To_ProjChar
- (
- ProjChar* pProjCh_Out,
- unsigned int MaxSize, /* includes NULL-terminator; truncates after this */
-
- LPTSTR lptszANSI_In
- );
- #endif
-
- /* Emulation of <string.h> *******************************************/
- extern unsigned int STRUTIL_SC_Strlen
- (
- const ProjChar* pProjCh_In
- );
-
- extern ProjChar* STRUTIL_SC_StrCpy
- (
- ProjChar* pProjCh_Dst,
- const ProjChar* pProjCh_Src
- );
-
- extern void STRUTIL_SC_FastCat
- (
- ProjChar* pProjCh_Dst,
- const ProjChar* pProjCh_Src_0,
- const ProjChar* pProjCh_Src_1
- );
- /* This function assumes the destination area is large enough;
- it copies Src0 followed by Src1 to the dest area.
- */
-
- extern OurBool STRUTIL_SC_Strequal
- (
- const ProjChar* pProjCh_1,
- const ProjChar* pProjCh_2
- );
-
- extern OurBool STRUTIL_SC_Strequal_Insensitive
- (
- const ProjChar* pProjCh_1,
- const ProjChar* pProjCh_2
- );
- /*
- these functions copy at most MaxSize chars from Src to Dst; this INCLUDES
- space used by a NULL terminator (so that you can pass it an array
- for the destination together with its size. The return value is
- whether the entire string was copied.
- */
- extern OurBool STRUTIL_SC_SafeCopy
- (
- ProjChar* pProjCh_Dst,
- unsigned int MaxSize,
-
- const ProjChar* pProjCh_Src
- );
-
- extern void STRUTIL_SC_SafeCat
- (
- ProjChar* pProjCh_Dst,
- unsigned int MaxSize,
-
- const ProjChar* pProjCh_Add
- );
-
- extern size_t STRUTIL_SC_NumBytes
- (
- const ProjChar* pProjCh
- );
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/tallfont.cpp b/3dc/avp/support/tallfont.cpp
deleted file mode 100644
index 11f6982..0000000
--- a/3dc/avp/support/tallfont.cpp
+++ /dev/null
@@ -1,1709 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: tallfont.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 18/3/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-
- #include "db.h"
- #include "dxlog.h"
-
- #include "tallfont.hpp"
-
- #include "awTexLd.h"
- #include "alt_tab.h"
-
- #include "ffstdio.h"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
- #define UseSoftwareAlphaRendering Yes
- // an option which assumes you're in a 16-bit graphic mode...
-
- #if UseSoftwareAlphaRendering
- #include "inline.h"
- #endif
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
-
- extern unsigned char *ScreenBuffer;
- extern long BackBufferPitch;
- extern LPDIRECTDRAWSURFACE lpDDSBack;
- extern DDPIXELFORMAT DisplayPixelFormat;
- extern int CloudTable[128][128];
- extern int CloakingPhase;
-
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class IndexedFont_Proportional_Column : public IndexedFont_Proportional
-// public:
-void
-IndexedFont_Proportional_Column :: RenderChar_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- // Easy first attempt: pass on to unclipped routine, but only if no clipping
- // required. Otherwise ignore...
- if
- (
- r2rect
- (
- R2Pos_Cursor,
- GetWidth(ProjCh),
- GetHeight()
- ) . bFitsIn( R2Rect_Clip )
- )
- {
- RenderChar_Unclipped
- (
- R2Pos_Cursor,
- FixP_Alpha,
- ProjCh
- );
- }
- else
- {
- R2Pos_Cursor . x += GetWidth(ProjCh);
- }
-}
-
-void
-IndexedFont_Proportional_Column :: RenderChar_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- #if 1
- unsigned int theOffset;
-
- if (ProjCh == ' ')
- {
- // Space is a special case:
- R2Pos_Cursor . x += SpaceWidth();
- return;
- }
-
- if
- (
- GetOffset
- (
- theOffset,
- ProjCh
- )
- )
- {
- if
- (
- GetWidth(ProjCh)>0
- )
- {
- RECT destRect;
-
- destRect.left = R2Pos_Cursor . x;
- destRect.top = R2Pos_Cursor . y;
-
- R2Pos_Cursor . x += GetWidth(ProjCh);
-
- destRect.right = R2Pos_Cursor . x++;
- destRect.bottom = R2Pos_Cursor . y + GetHeight();
-
- RECT tempnonConstRECTSoThatItCanWorkWithMicrosoft = WindowsRectForOffset[ theOffset ];
-
- #if 0
- DDBLTFX tempDDBltFx;
-
- memset(&tempDDBltFx,0,sizeof(DDBLTFX));
- tempDDBltFx . dwSize = sizeof(DDBLTFX);
-
- tempDDBltFx . ddckSrcColorkey . dwColorSpaceLowValue = 0;
- tempDDBltFx . ddckSrcColorkey . dwColorSpaceHighValue = 0;
- #endif
-
- HRESULT ddrval = lpDDSBack->Blt
- (
- &destRect,
- image_ptr,
- &tempnonConstRECTSoThatItCanWorkWithMicrosoft,
- (
- DDBLT_WAIT
- #if 1
- | DDBLT_KEYSRC
- #else
- | DDBLT_KEYSRCOVERRIDE
- #endif
-
- #if 0
- | DDBLT_ALPHADEST
- #endif
- ),
- NULL
- // &tempDDBltFx // LPDDBLTFX lpDDBltFx
- );
-
-
- #if 0
- // or even:
- ddrval = lpDDSBack->BltFast(x, y,
- lpDDDbgFont, &source,
- DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
- #endif
-
- #if 0
- if(ddrval != DD_OK)
- {
- ReleaseDirect3D();
- exit(0x666009);
- }
- #endif
- }
- }
- #else
- textprintXY
- (
- R2Pos_Cursor . x,
- R2Pos_Cursor . y,
- "%c",
- ProjCh
- );
- #endif
-}
-
-int
-IndexedFont_Proportional_Column :: GetMaxWidth(void) const
-{
- return R2Size_OverallImage . w;
-}
-
-int
-IndexedFont_Proportional_Column :: GetWidth
-(
- ProjChar ProjCh_In
-) const
-{
- unsigned int offsetTemp;
-
- if (ProjCh_In == ' ')
- {
- return SpaceWidth();
- }
-
- if
- (
- GetOffset
- (
- offsetTemp,
- ProjCh_In
- )
- )
- {
- return WidthForOffset[ offsetTemp ];
- }
- else
- {
- return 0;
- }
-}
-
-// static
-IndexedFont_Proportional_Column* IndexedFont_Proportional_Column :: Create
-(
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
-)
-{
- IndexedFont_Proportional_Column* pFont = new IndexedFont_Proportional_Column
- (
- I_Font_New,
- Filename,
- HeightPerChar_New,
- SpaceWidth_New,
- ASCIICodeForInitialCharacter
- );
-
- SCString :: UpdateAfterFontChange( I_Font_New );
-
- return pFont;
-}
-
-
-IndexedFont_Proportional_Column :: ~IndexedFont_Proportional_Column()
-{
- GLOBALASSERT(image_ptr);
- ATRemoveSurface(image_ptr);
- ReleaseDDSurface(image_ptr);
- image_ptr = NULL;
-
- if (hBackup)
- {
- AwDestroyBackupTexture(hBackup);
- }
-
- hBackup = NULL;
-}
-
-IndexedFont_Proportional_Column :: IndexedFont_Proportional_Column
-(
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
-) : IndexedFont_Proportional
- (
- I_Font_New
- ),
- ASCIICodeForOffset0
- (
- ASCIICodeForInitialCharacter
- ),
- HeightPerChar_Val(HeightPerChar_New),
- SpaceWidth_Val(SpaceWidth_New),
- NumChars(0)
-{
- {
- unsigned nWidth,nHeight;
-
- //see if graphic can be found in fast file
- unsigned int fastFileLength;
- void const * pFastFileData = ffreadbuf(Filename,&fastFileLength);
-
- if(pFastFileData)
- {
- //load from fast file
- image_ptr = AwCreateSurface
- (
- "pxfXYB",
- pFastFileData,
- fastFileLength,
- (
- #if 1
- 0
- #else
- AW_TLF_TRANSP
- #endif
- #if 0
- | AW_TLF_CHROMAKEY
- #endif
- ),
- &nWidth,
- &nHeight,
- &hBackup
- );
- }
- else
- {
- //load graphic from rim file
- image_ptr = AwCreateSurface
- (
- "sfXYB",
- Filename,
- (
- #if 1
- 0
- #else
- AW_TLF_TRANSP
- #endif
- #if 0
- | AW_TLF_CHROMAKEY
- #endif
- ),
- &nWidth,
- &nHeight,
- &hBackup
- );
- }
- R2Size_OverallImage . w = nWidth;
- R2Size_OverallImage . h = nHeight;
- }
-
- GLOBALASSERT(image_ptr);
- GLOBALASSERT(hBackup);
-
- GLOBALASSERT(R2Size_OverallImage . w>0);
- GLOBALASSERT(R2Size_OverallImage . h>0);
- ATIncludeSurface(image_ptr,hBackup);
-
- DDCOLORKEY tempDDColorKey;
-
- tempDDColorKey . dwColorSpaceLowValue = 0;
- tempDDColorKey . dwColorSpaceHighValue = 0;
-
-
- HRESULT hrSetColorKey = image_ptr -> SetColorKey
- (
- (
- DDCKEY_SRCBLT
- ), // DWORD dwFlags,
- &tempDDColorKey // LPDDCOLORKEY lpDDColorKey
- );
-
- if ( hrSetColorKey != DD_OK )
- {
- LOGDXERR(hrSetColorKey);
- }
-
-#if 0
-
-typedef struct _DDCOLORKEY{
- DWORD dwColorSpaceLowValue;
- DWORD dwColorSpaceHighValue;
-} DDCOLORKEY,FAR* LPDDCOLORKEY;
-
- Parameters
-
- dwFlags
-
- Determines which color key is requested.
-
- DDCKEY_COLORSPACE
- Set if the structure contains a color space. Not set if the structure contains a single color key.
- DDCKEY_DESTBLT
- Set if the structure specifies a color key or color space to be used as a destination color key for blit operations.
- DDCKEY_DESTOVERLAY
- Set if the structure specifies a color key or color space to be used as a destination color key for overlay operations.
- DDCKEY_SRCBLT
- Set if the structure specifies a color key or color space to be used as a source color key for blit operations.
- DDCKEY_SRCOVERLAY
- Set if the structure specifies a color key or color space to be used as a source color key for overlay operations.
- lpDDColorKey
-
- Address of the DDCOLORKEY structure that contains the new color key values for the DirectDrawSurface object.
-#endif
-
-
-
-
- NumChars = (R2Size_OverallImage . h)/HeightPerChar_Val;
-
- GLOBALASSERT( NumChars < MAX_CHARS_IN_TALLFONT );
-
- for (int i=0;i<NumChars;i++)
- {
- WindowsRectForOffset[ i ] . top = (i*HeightPerChar_Val);
- WindowsRectForOffset[ i ] . bottom = ((i+1)*HeightPerChar_Val);
- WindowsRectForOffset[ i ] . left = 0;
- WindowsRectForOffset[ i ] . right = R2Size_OverallImage . w;
-
- WidthForOffset[ i ] = R2Size_OverallImage . w;
- }
-
- UpdateWidths();
-
-}
-
-void
-IndexedFont_Proportional_Column :: UpdateWidths(void)
-{
- // called by constructor
-
- // Test: read the surface:
- {
- // LPDIRECTDRAWSURFACE image_ptr;
-
- DDSURFACEDESC tempDDSurfaceDesc;
-
- tempDDSurfaceDesc . dwSize = sizeof(DDSURFACEDESC);
-
- HRESULT hrLock = image_ptr -> Lock
- (
- NULL, // LPRECT lpDestRect,
- &tempDDSurfaceDesc, // LPDDSURFACEDESC lpDDSurfaceDesc,
- (
- DDLOCK_READONLY
- | DDLOCK_SURFACEMEMORYPTR
- #if 0
- | DDLOCK_WAIT
- | DDLOCK_NOSYSLOCK
- #endif
- ), // DWORD dwFlags,
- NULL // HANDLE hEvent
- );
-
- if ( hrLock != DD_OK )
- {
- // ought really to throw an exception
-
- LOGDXERR(hrLock);
- return;
- }
-
- // Read the data...
- {
- for (int iOffset=0;iOffset<NumChars;iOffset++)
- {
- int y = iOffset * HeightPerChar_Val;
- int x = ( R2Size_OverallImage . w - 1);
-
- #if 0
- db_logf1(("Character offset %i",iOffset));
- #endif
-
- while (x>0)
- {
- if
- (
- bAnyNonTransparentPixelsInColumn
- (
- r2pos(x,y), // r2pos R2Pos_TopOfColumn,
- HeightPerChar_Val, // int HeightOfColumn
- &tempDDSurfaceDesc // LPDDSURFACEDESC lpDDSurfaceDesc
- )
- )
- {
- break;
- // and the current value of (x+1) is the width to use
- }
-
- x--;
- }
-
- SetWidth(iOffset,x+1);
- }
- }
-
-
- HRESULT hrUnlock = image_ptr -> Unlock
- (
- NULL // LPVOID lpSurfaceData
- );
-
-
- if ( hrUnlock != DD_OK )
- {
- // ought really to throw an exception
-
- LOGDXERR(hrUnlock);
- return;
- }
- }
-}
-
-// static
-OurBool
-IndexedFont_Proportional_Column :: bAnyNonTransparentPixelsInColumn
-(
- r2pos R2Pos_TopOfColumn,
- int HeightOfColumn,
- LPDDSURFACEDESC lpDDSurfaceDesc
- // assumes you have a read lock
-)
-{
- GLOBALASSERT( lpDDSurfaceDesc );
-
- void* pSurface = lpDDSurfaceDesc -> lpSurface;
-
- int BytesPerPixel = lpDDSurfaceDesc -> ddpfPixelFormat . dwRGBBitCount /8;
-
- int BytesPerRow =
- (
- #if 0
- (BytesPerPixel * lpDDSurfaceDesc -> dwWidth)
- +
- #endif
- lpDDSurfaceDesc -> lPitch
- );
-
- int y = R2Pos_TopOfColumn . y;
-
- #if 0
- db_logf1(("x=%i",R2Pos_TopOfColumn . x));
- #endif
-
- while ( y < R2Pos_TopOfColumn . y + HeightOfColumn )
- {
- int Pixel =
- (
- *(int*)
- (
- ((char*)pSurface)
- +
- ( y * BytesPerRow )
- +
- (R2Pos_TopOfColumn . x * BytesPerPixel)
- )
- );
-
- int R = Pixel & lpDDSurfaceDesc -> ddpfPixelFormat . dwRBitMask;
- int G = Pixel & lpDDSurfaceDesc -> ddpfPixelFormat . dwGBitMask;
- int B = Pixel & lpDDSurfaceDesc -> ddpfPixelFormat . dwBBitMask;
-
- #if 0
- db_logf1(("y=%i",y));
- db_logf1(("Pixel=0x%x",Pixel));
- db_logf1(("R=0x%x",R));
- db_logf1(("G=0x%x",G));
- db_logf1(("B=0x%x",B));
- #endif
-
- #if 1
- if (Pixel > 0 )
- {
- return Yes;
- }
- #else
- if
- (
- (R > 32)
- ||
- (G > 32)
- ||
- (B > 32)
- )
- {
- // nasty hack to get it working...
- return Yes;
- }
- #endif
-
- y++;
- }
-
- return No;
-}
-
-
-
-
-
-
-/////////////////////////////////////////////////////////////////
-// 3/4/98 DHM: A new implementation, supporting character kerning
-/////////////////////////////////////////////////////////////////
-
-// class IndexedFont_Kerned_Column : public IndexedFont_Kerned
-// public:
-void
-IndexedFont_Kerned_Column :: RenderChar_Clipped
-(
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- unsigned int theOffset;
-
- if (ProjCh == ' ')
- {
- // Space is a special case:
- return;
- }
-
- if
- (
- GetOffset
- (
- theOffset,
- ProjCh
- )
- )
- {
- if
- (
- GetWidth(ProjCh)>0
- )
- {
- {
- // This code adapted from DrawGraphicWithAlphaChannel();
- // it assumes you're in a 16-bit mode...
- DDSURFACEDESC ddsdimage;
-
- memset(&ddsdimage, 0, sizeof(ddsdimage));
- ddsdimage.dwSize = sizeof(ddsdimage);
-
- /* lock the image */
- while (image_ptr->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);
-
- // okay, now we have the surfaces, we can copy from one to the other,
- // darkening pixels as we go
- {
- long fontimagePitchInShorts = (ddsdimage.lPitch/2);
- long backbufferPitchInShorts = (BackBufferPitch/2);
-
- unsigned short* fontimageRowStartPtr =
- (
- ((unsigned short *)ddsdimage.lpSurface)
- +
- (GetHeight()*theOffset*fontimagePitchInShorts)
- );
-
- unsigned short* backbufferRowStartPtr =
- (
- ((unsigned short *)ScreenBuffer)
- +
- (R2Pos_Cursor.y*backbufferPitchInShorts)
- +
- (R2Pos_Cursor.x)
- );
- int screenY = R2Pos_Cursor.y;
-
- for (int yCount=GetHeight(); yCount>0; yCount--)
- {
- unsigned short* fontimagePtr = fontimageRowStartPtr;
- unsigned short* backbufferPtr = backbufferRowStartPtr;
-
- if (screenY >= R2Rect_Clip.y0 && screenY <= R2Rect_Clip.y1)
- for (int xCount=FullWidthForOffset[theOffset]; xCount>0;xCount--)
- {
- int r = CloudTable[(xCount+R2Pos_Cursor.x+CloakingPhase/64)&127][(screenY+CloakingPhase/128)&127];
-// b += CloudTable[((xCount+R2Pos_Cursor.x)/2-CloakingPhase/96)&127][((yCount+R2Pos_Cursor.y)/4+CloakingPhase/64)&127]/4;
-// b += CloudTable[((xCount+R2Pos_Cursor.x+10)/4-CloakingPhase/64)&127][((yCount+R2Pos_Cursor.y-50)/8+CloakingPhase/32)&127]/8;
-// if (b>ONE_FIXED) b = ONE_FIXED;
- r = MUL_FIXED(FixP_Alpha,r);
- if (*fontimagePtr)
- {
- unsigned int backR = (int)(*backbufferPtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int backG = (int)(*backbufferPtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int backB = (int)(*backbufferPtr) & DisplayPixelFormat.dwBBitMask;
-
- unsigned int fontR = (int)(*fontimagePtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int fontG = (int)(*fontimagePtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int fontB = (int)(*fontimagePtr) & DisplayPixelFormat.dwBBitMask;
-
- backR += MUL_FIXED(r,fontR);
- if (backR>DisplayPixelFormat.dwRBitMask) backR = DisplayPixelFormat.dwRBitMask;
- else backR &= DisplayPixelFormat.dwRBitMask;
-
- backG += MUL_FIXED(r,fontG);
- if (backG>DisplayPixelFormat.dwGBitMask) backG = DisplayPixelFormat.dwGBitMask;
- else backG &= DisplayPixelFormat.dwGBitMask;
-
- backB += MUL_FIXED(r,fontB);
- if (backB>DisplayPixelFormat.dwBBitMask) backB = DisplayPixelFormat.dwBBitMask;
- else backB &= DisplayPixelFormat.dwBBitMask;
-
- *backbufferPtr = (short)(backR|backG|backB);
- }
- fontimagePtr++;
- backbufferPtr++;
- }
- screenY++;
- fontimageRowStartPtr += fontimagePitchInShorts;
- backbufferRowStartPtr += backbufferPitchInShorts;
- }
- }
-
- image_ptr->Unlock((LPVOID)ddsdimage.lpSurface);
- }
- }
- }
-}
-
-void
-IndexedFont_Kerned_Column :: RenderChar_Unclipped
-(
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
-) const
-{
- unsigned int theOffset;
-
- if (ProjCh == ' ')
- {
- // Space is a special case:
- return;
- }
-
- if
- (
- GetOffset
- (
- theOffset,
- ProjCh
- )
- )
- {
- if
- (
- GetWidth(ProjCh)>0
- )
- {
- {
- // This code adapted from DrawGraphicWithAlphaChannel();
- // it assumes you're in a 16-bit mode...
- DDSURFACEDESC ddsdback, ddsdimage;
-
- memset(&ddsdback, 0, sizeof(ddsdback));
- memset(&ddsdimage, 0, sizeof(ddsdimage));
- ddsdback.dwSize = sizeof(ddsdback);
- ddsdimage.dwSize = sizeof(ddsdimage);
-
- /* lock the image */
- while (image_ptr->Lock(NULL, &ddsdimage, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);
-
- /* lock the backbuffer */
- while (lpDDSBack->Lock(NULL, &ddsdback, DDLOCK_WAIT, NULL) == DDERR_WASSTILLDRAWING);
-
- // okay, now we have the surfaces, we can copy from one to the other,
- // darkening pixels as we go
- {
- long fontimagePitchInShorts = (ddsdimage.lPitch/2);
- long backbufferPitchInShorts = (ddsdback.lPitch/2);
-
- unsigned short* fontimageRowStartPtr =
- (
- ((unsigned short *)ddsdimage.lpSurface)
- +
- (GetHeight()*theOffset*fontimagePitchInShorts)
- );
-
- unsigned short* backbufferRowStartPtr =
- (
- ((unsigned short *)ddsdback.lpSurface)
- +
- (R2Pos_Cursor.y*backbufferPitchInShorts)
- +
- (R2Pos_Cursor.x)
- );
-
- for (int yCount=GetHeight(); yCount>0; yCount--)
- {
- unsigned short* fontimagePtr = fontimageRowStartPtr;
- unsigned short* backbufferPtr = backbufferRowStartPtr;
- int yIndex = (yCount+R2Pos_Cursor.y+CloakingPhase/128)&127;
- int xIndex = R2Pos_Cursor.x+CloakingPhase/64;
-
- for (int xCount=FullWidthForOffset[theOffset]; xCount>0;xCount--)
- {
- int r = CloudTable[(xCount+xIndex)&127][yIndex];
-// b += CloudTable[((xCount+R2Pos_Cursor.x)/2-CloakingPhase/96)&127][((yCount+R2Pos_Cursor.y)/4+CloakingPhase/64)&127]/4;
-// b += CloudTable[((xCount+R2Pos_Cursor.x+10)/4-CloakingPhase/64)&127][((yCount+R2Pos_Cursor.y-50)/8+CloakingPhase/32)&127]/8;
-// if (b>ONE_FIXED) b = ONE_FIXED;
- r = MUL_FIXED(FixP_Alpha,r);
- if (*fontimagePtr)
- {
- unsigned int backR = (int)(*backbufferPtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int backG = (int)(*backbufferPtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int backB = (int)(*backbufferPtr) & DisplayPixelFormat.dwBBitMask;
-
- unsigned int fontR = (int)(*fontimagePtr) & DisplayPixelFormat.dwRBitMask;
- unsigned int fontG = (int)(*fontimagePtr) & DisplayPixelFormat.dwGBitMask;
- unsigned int fontB = (int)(*fontimagePtr) & DisplayPixelFormat.dwBBitMask;
-
- backR += MUL_FIXED(r,fontR);
- if (backR>DisplayPixelFormat.dwRBitMask) backR = DisplayPixelFormat.dwRBitMask;
- else backR &= DisplayPixelFormat.dwRBitMask;
-
- backG += MUL_FIXED(r,fontG);
- if (backG>DisplayPixelFormat.dwGBitMask) backG = DisplayPixelFormat.dwGBitMask;
- else backG &= DisplayPixelFormat.dwGBitMask;
-
- backB += MUL_FIXED(r,fontB);
- if (backB>DisplayPixelFormat.dwBBitMask) backB = DisplayPixelFormat.dwBBitMask;
- else backB &= DisplayPixelFormat.dwBBitMask;
-
- *backbufferPtr = (short)(backR|backG|backB);
- }
- fontimagePtr++;
- backbufferPtr++;
- }
-
- fontimageRowStartPtr += fontimagePitchInShorts;
- backbufferRowStartPtr += backbufferPitchInShorts;
- }
- }
-
- lpDDSBack->Unlock((LPVOID)ddsdback.lpSurface);
- image_ptr->Unlock((LPVOID)ddsdimage.lpSurface);
- }
- }
- }
-}
-
-int
-IndexedFont_Kerned_Column :: GetMaxWidth(void) const
-{
- return R2Size_OverallImage . w;
-}
-
-int
-IndexedFont_Kerned_Column :: GetWidth
-(
- ProjChar ProjCh_In
-) const
-{
- unsigned int offsetTemp;
-
- if (ProjCh_In == ' ')
- {
- return SpaceWidth();
- }
-
- if
- (
- GetOffset
- (
- offsetTemp,
- ProjCh_In
- )
- )
- {
- return FullWidthForOffset[ offsetTemp ];
- }
- else
- {
- return 0;
- }
-}
-
-int
-IndexedFont_Kerned_Column :: GetXInc
-(
- ProjChar currentProjCh,
- ProjChar nextProjCh
-) const
-{
- GLOBALASSERT(currentProjCh!='\0');
- // LOCALISEME
-
- if (currentProjCh == ' ')
- {
- return SpaceWidth();
- }
-
- if (!((nextProjCh>='0' && nextProjCh<=']') || (nextProjCh>='a' && nextProjCh<='}')))
- {
- return GetWidth(currentProjCh);
- }
-
- unsigned int currentOffset;
-
- if
- (
- GetOffset
- (
- currentOffset,
- currentProjCh
- )
- )
- {
- unsigned int nextOffset;
-
- if
- (
- GetOffset
- (
- nextOffset,
- nextProjCh
- )
- )
- {
- return XIncForOffset[currentOffset][nextOffset];
- }
- else
- {
- return FullWidthForOffset[currentOffset];
- }
- }
- else
- {
- return 0;
- }
-
-}
-
-
-// static
-IndexedFont_Kerned_Column* IndexedFont_Kerned_Column :: Create
-(
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
-)
-{
- IndexedFont_Kerned_Column* pFont = new IndexedFont_Kerned_Column
- (
- I_Font_New,
- Filename,
- HeightPerChar_New,
- SpaceWidth_New,
- ASCIICodeForInitialCharacter
- );
-
- SCString :: UpdateAfterFontChange( I_Font_New );
-
- return pFont;
-}
-
-
-IndexedFont_Kerned_Column :: ~IndexedFont_Kerned_Column()
-{
- GLOBALASSERT(image_ptr);
- ATRemoveSurface(image_ptr);
- ReleaseDDSurface(image_ptr);
- image_ptr = NULL;
-
- if (hBackup)
- {
- AwDestroyBackupTexture(hBackup);
- }
-
- hBackup = NULL;
-}
-
-IndexedFont_Kerned_Column :: IndexedFont_Kerned_Column
-(
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
-) : IndexedFont_Kerned
- (
- I_Font_New
- ),
- ASCIICodeForOffset0
- (
- ASCIICodeForInitialCharacter
- ),
- HeightPerChar_Val(HeightPerChar_New),
- SpaceWidth_Val(SpaceWidth_New),
- NumChars(0)
-{
- {
- unsigned nWidth,nHeight;
-
- //see if graphic can be found in fast file
- unsigned int fastFileLength;
- void const * pFastFileData = ffreadbuf(Filename,&fastFileLength);
-
- if(pFastFileData)
- {
- //load from fast file
- image_ptr = AwCreateSurface
- (
- "pxfXYB",
- pFastFileData,
- fastFileLength,
- (
- #if 1
- 0
- #else
- AW_TLF_TRANSP
- #endif
- #if 0
- | AW_TLF_CHROMAKEY
- #endif
- ),
- &nWidth,
- &nHeight,
- &hBackup
- );
- }
- else
- {
- //load graphic from rim file
- image_ptr = AwCreateSurface
- (
- "sfXYB",
- Filename,
- (
- #if 1
- 0
- #else
- AW_TLF_TRANSP
- #endif
- #if 0
- | AW_TLF_CHROMAKEY
- #endif
- ),
- &nWidth,
- &nHeight,
- &hBackup
- );
- }
-
- R2Size_OverallImage . w = nWidth;
- R2Size_OverallImage . h = nHeight;
- }
-
- GLOBALASSERT(image_ptr);
- GLOBALASSERT(hBackup);
-
- GLOBALASSERT(R2Size_OverallImage . w>0);
- GLOBALASSERT(R2Size_OverallImage . h>0);
- ATIncludeSurface(image_ptr,hBackup);
-
- DDCOLORKEY tempDDColorKey;
-
- tempDDColorKey . dwColorSpaceLowValue = 0;
- tempDDColorKey . dwColorSpaceHighValue = 0;
-
-
- HRESULT hrSetColorKey = image_ptr -> SetColorKey
- (
- (
- DDCKEY_SRCBLT
- ), // DWORD dwFlags,
- &tempDDColorKey // LPDDCOLORKEY lpDDColorKey
- );
-
- if ( hrSetColorKey != DD_OK )
- {
- LOGDXERR(hrSetColorKey);
- }
-
-#if 0
-
-typedef struct _DDCOLORKEY{
- DWORD dwColorSpaceLowValue;
- DWORD dwColorSpaceHighValue;
-} DDCOLORKEY,FAR* LPDDCOLORKEY;
-
- Parameters
-
- dwFlags
-
- Determines which color key is requested.
-
- DDCKEY_COLORSPACE
- Set if the structure contains a color space. Not set if the structure contains a single color key.
- DDCKEY_DESTBLT
- Set if the structure specifies a color key or color space to be used as a destination color key for blit operations.
- DDCKEY_DESTOVERLAY
- Set if the structure specifies a color key or color space to be used as a destination color key for overlay operations.
- DDCKEY_SRCBLT
- Set if the structure specifies a color key or color space to be used as a source color key for blit operations.
- DDCKEY_SRCOVERLAY
- Set if the structure specifies a color key or color space to be used as a source color key for overlay operations.
- lpDDColorKey
-
- Address of the DDCOLORKEY structure that contains the new color key values for the DirectDrawSurface object.
-#endif
-
-
-
-
- NumChars = (R2Size_OverallImage . h)/HeightPerChar_Val;
-
- GLOBALASSERT( NumChars < MAX_CHARS_IN_TALLFONT );
-
- for (int i=0;i<NumChars;i++)
- {
- WindowsRectForOffset[ i ] . top = (i*HeightPerChar_Val);
- WindowsRectForOffset[ i ] . bottom = ((i+1)*HeightPerChar_Val);
- WindowsRectForOffset[ i ] . left = 0;
- WindowsRectForOffset[ i ] . right = R2Size_OverallImage . w;
-
- FullWidthForOffset[ i ] = R2Size_OverallImage . w;
- }
-
- UpdateWidths();
- UpdateXIncs();
-}
-
-void
-IndexedFont_Kerned_Column :: UpdateWidths(void)
-{
- // called by constructor
-
- // Test: read the surface:
- {
- // LPDIRECTDRAWSURFACE image_ptr;
-
- DDSURFACEDESC tempDDSurfaceDesc;
-
- tempDDSurfaceDesc . dwSize = sizeof(DDSURFACEDESC);
-
- HRESULT hrLock = image_ptr -> Lock
- (
- NULL, // LPRECT lpDestRect,
- &tempDDSurfaceDesc, // LPDDSURFACEDESC lpDDSurfaceDesc,
- (
- DDLOCK_READONLY
- | DDLOCK_SURFACEMEMORYPTR
- #if 0
- | DDLOCK_WAIT
- | DDLOCK_NOSYSLOCK
- #endif
- ), // DWORD dwFlags,
- NULL // HANDLE hEvent
- );
-
- if ( hrLock != DD_OK )
- {
- // ought really to throw an exception
-
- LOGDXERR(hrLock);
- return;
- }
-
- // Read the data...
- {
- for (int iOffset=0;iOffset<NumChars;iOffset++)
- {
- int y = iOffset * HeightPerChar_Val;
- int x = ( R2Size_OverallImage . w - 1);
-
- #if 0
- db_logf1(("Character offset %i",iOffset));
- #endif
-
- while (x>0)
- {
- if
- (
- bAnyNonTransparentPixelsInColumn
- (
- r2pos(x,y), // r2pos R2Pos_TopOfColumn,
- HeightPerChar_Val, // int HeightOfColumn
- &tempDDSurfaceDesc // LPDDSURFACEDESC lpDDSurfaceDesc
- )
- )
- {
- break;
- // and the current value of (x+1) is the width to use
- }
-
- x--;
- }
-
- SetWidth(iOffset,x+1);
- }
- }
-
-
- HRESULT hrUnlock = image_ptr -> Unlock
- (
- NULL // LPVOID lpSurfaceData
- );
-
-
- if ( hrUnlock != DD_OK )
- {
- // ought really to throw an exception
-
- LOGDXERR(hrUnlock);
- return;
- }
- }
-}
-
-void
-IndexedFont_Kerned_Column :: UpdateXIncs(void)
-{
- DDSURFACEDESC tempDDSurfaceDesc;
-
- tempDDSurfaceDesc . dwSize = sizeof(DDSURFACEDESC);
-
- HRESULT hrLock = image_ptr -> Lock
- (
- NULL, // LPRECT lpDestRect,
- &tempDDSurfaceDesc, // LPDDSURFACEDESC lpDDSurfaceDesc,
- (
- DDLOCK_READONLY
- | DDLOCK_SURFACEMEMORYPTR
- #if 0
- | DDLOCK_WAIT
- | DDLOCK_NOSYSLOCK
- #endif
- ), // DWORD dwFlags,
- NULL // HANDLE hEvent
- );
-
- if ( hrLock != DD_OK )
- {
- // ought really to throw an exception
- LOGDXERR(hrLock);
-
- // fill table up with sensible values:
- for (int i=0;i<NumChars;i++)
- {
- for (int j=0;j<NumChars;j++)
- {
- XIncForOffset[i][j] = FullWidthForOffset[i];
- }
- }
- return;
- }
-
- int RowsToProcess = NumChars*GetHeight();
- int* minOpaqueX = new int[RowsToProcess];
- int* maxOpaqueX = new int[RowsToProcess];
-
- // Build tables of min/max opaque pixels in each row of the image:
- {
- for (int Row=0;Row<RowsToProcess;Row++)
- {
- // Find right-most pixel in row
- {
- int rightmostX=GetMaxWidth()-1;
- while (rightmostX>0)
- {
- if
- (
- bOpaque
- (
- &tempDDSurfaceDesc,
- rightmostX, // int x,
- Row
- )
- )
- {
- break;
- }
- else
- {
- rightmostX--;
- }
- }
-
- maxOpaqueX[Row]=rightmostX;
- }
-
- // Find left-most pixel in row of second character
- {
- int leftmostX=0;
- while(leftmostX<GetMaxWidth())
- {
- if
- (
- bOpaque
- (
- &tempDDSurfaceDesc,
- leftmostX, // int x,
- Row // int y
- )
- )
- {
- break;
- }
- else
- {
- leftmostX++;
- }
- }
- minOpaqueX[Row]=leftmostX;
- }
- }
- }
-
- HRESULT hrUnlock = image_ptr -> Unlock
- (
- NULL // LPVOID lpSurfaceData
- );
-
-
- if ( hrUnlock != DD_OK )
- {
- // ought really to throw an exception
- LOGDXERR(hrUnlock);
-
- // fill table up with sensible values:
- for (int i=0;i<NumChars;i++)
- {
- for (int j=0;j<NumChars;j++)
- {
- XIncForOffset[i][j] = FullWidthForOffset[i];
- }
- }
- return;
- }
- else
- {
- // Use the table of opaque extents:
-
- for (int i=0;i<NumChars;i++)
- {
- for (int j=0;j<NumChars;j++)
- {
- int XInc = CalcXInc
- (
- i, // unsigned int currentOffset,
- j, // unsigned int nextOffset,
- minOpaqueX,
- maxOpaqueX
- );
-
- GLOBALASSERT(XInc>=0);
- #if 0
- GLOBALASSERT(XInc<=GetMaxWidth());
- #endif
-
- XIncForOffset[i][j] =XInc;
- }
- }
- }
-
- // Destroy the table of opaque extents:
- {
- delete[] maxOpaqueX;
- delete[] minOpaqueX;
- }
-
-}
-
-
-// static
-OurBool
-IndexedFont_Kerned_Column :: bAnyNonTransparentPixelsInColumn
-(
- r2pos R2Pos_TopOfColumn,
- int HeightOfColumn,
- LPDDSURFACEDESC lpDDSurfaceDesc
- // assumes you have a read lock
-)
-{
- GLOBALASSERT( lpDDSurfaceDesc );
-
- void* pSurface = lpDDSurfaceDesc -> lpSurface;
-
- int BytesPerPixel = lpDDSurfaceDesc -> ddpfPixelFormat . dwRGBBitCount /8;
-
- int BytesPerRow =
- (
- lpDDSurfaceDesc -> lPitch
- );
-
- int y = R2Pos_TopOfColumn . y;
-
- #if 0
- db_logf1(("x=%i",R2Pos_TopOfColumn . x));
- #endif
-
- while ( y < R2Pos_TopOfColumn . y + HeightOfColumn )
- {
- int Pixel =
- (
- *(int*)
- (
- ((char*)pSurface)
- +
- ( y * BytesPerRow )
- +
- (R2Pos_TopOfColumn . x * BytesPerPixel)
- )
- );
-
- int R = Pixel & lpDDSurfaceDesc -> ddpfPixelFormat . dwRBitMask;
- int G = Pixel & lpDDSurfaceDesc -> ddpfPixelFormat . dwGBitMask;
- int B = Pixel & lpDDSurfaceDesc -> ddpfPixelFormat . dwBBitMask;
-
- #if 0
- db_logf1(("y=%i",y));
- db_logf1(("Pixel=0x%x",Pixel));
- db_logf1(("R=0x%x",R));
- db_logf1(("G=0x%x",G));
- db_logf1(("B=0x%x",B));
- #endif
-
- #if 1
- if (Pixel > 0 )
- {
- return Yes;
- }
- #else
- if
- (
- (R > 32)
- ||
- (G > 32)
- ||
- (B > 32)
- )
- {
- // nasty hack to get it working...
- return Yes;
- }
- #endif
-
- y++;
- }
-
- return No;
-}
-
-int
-IndexedFont_Kerned_Column :: CalcXInc
-(
- unsigned int currentOffset,
- unsigned int nextOffset,
- int* minOpaqueX,
- int* maxOpaqueX
-)
-{
- GLOBALASSERT(currentOffset<NumChars);
- GLOBALASSERT(nextOffset<NumChars);
- GLOBALASSERT( minOpaqueX );
- GLOBALASSERT( maxOpaqueX );
-
- // Compare rows in the pair of images (they have the same height)
- // First idea:
- // Iterate through X-inc values, finding the smallest
- // one which is "valid" for all rows.
- // "Valid" means there's no overlapping of non-transparent pixels
- // when the second image is displaced by the X-inc.
- // Tried this, but it took too long.
-
- // Second attempt:
- // Iterate through all rows, finding smallest X-inc which is valid
- // for each row, and maintaining what is the biggest "smallest X-inc"
- // you have so far. This will be the return value.
-
- #if 1
- {
- int Biggest_MinXInc = 0;
- for (int Row=0;Row<GetHeight();Row++)
- {
- int MinXIncForRow = GetSmallestXIncForRow
- (
- currentOffset,
- nextOffset,
- minOpaqueX,
- maxOpaqueX,
- Row
- );
-
- if (MinXIncForRow > Biggest_MinXInc)
- {
- Biggest_MinXInc = MinXIncForRow;
- }
- }
-
- return Biggest_MinXInc;
- }
- #else
- return FullWidthForOffset[currentOffset];
- #endif
-}
-
-OurBool
-IndexedFont_Kerned_Column :: OverlapOnRow
-(
- unsigned int currentOffset,
- unsigned int nextOffset,
- int Row,
- int ProposedXInc
-)
-{
- GLOBALASSERT(currentOffset<NumChars);
- GLOBALASSERT(nextOffset<NumChars);
-
- #if 1
- {
- DDSURFACEDESC tempDDSurfaceDesc;
-
- tempDDSurfaceDesc . dwSize = sizeof(DDSURFACEDESC);
-
- HRESULT hrLock = image_ptr -> Lock
- (
- NULL, // LPRECT lpDestRect,
- &tempDDSurfaceDesc, // LPDDSURFACEDESC lpDDSurfaceDesc,
- (
- DDLOCK_READONLY
- | DDLOCK_SURFACEMEMORYPTR
- #if 0
- | DDLOCK_WAIT
- | DDLOCK_NOSYSLOCK
- #endif
- ), // DWORD dwFlags,
- NULL // HANDLE hEvent
- );
-
- if ( hrLock != DD_OK )
- {
- // ought really to throw an exception
-
- LOGDXERR(hrLock);
- return Yes;
- }
-
- // Find right-most pixel in row of first character
- int rightmostX;
- int firstoffsetY = Row+(currentOffset*GetHeight());
- for (rightmostX=GetMaxWidth()-1;rightmostX>0;rightmostX--)
- {
- if
- (
- bOpaque
- (
- &tempDDSurfaceDesc, // LPDDSURFACEDESC lpDDSurfaceDesc
- rightmostX, // int x,
- firstoffsetY // int y
- )
- )
- {
- break;
- }
- }
-
- // Find left-most pixel in row of second character
- int leftmostX;
- int nextoffsetY = Row+(nextOffset*GetHeight());
- for (leftmostX=0;leftmostX<GetMaxWidth();leftmostX++)
- {
- if
- (
- bOpaque
- (
- &tempDDSurfaceDesc, // LPDDSURFACEDESC lpDDSurfaceDesc
- leftmostX, // int x,
- nextoffsetY // int y
- )
- )
- {
- break;
- }
- }
-
- // Is there an overlap when displaced by the proposed XInc?
- {
- return
- (
- (rightmostX)
- >=
- (leftmostX+ProposedXInc)
- );
- }
- }
- #else
- return Yes;
- // for now
- #endif
-}
-
-int
-IndexedFont_Kerned_Column :: GetSmallestXIncForRow
-(
- unsigned int currentOffset,
- unsigned int nextOffset,
- int* minOpaqueX,
- int* maxOpaqueX,
- unsigned int Row
-)
-{
- GLOBALASSERT( currentOffset < NumChars );
- GLOBALASSERT( nextOffset < NumChars );
- GLOBALASSERT( minOpaqueX );
- GLOBALASSERT( maxOpaqueX );
- GLOBALASSERT( Row < GetHeight() );
-
- {
- int Difference =
- (
- maxOpaqueX[Row+(currentOffset*GetHeight())] - minOpaqueX[Row+(nextOffset*GetHeight())]
- +1
- );
-
- if (Difference>0)
- {
- return Difference;
- }
- else
- {
- return 0;
- }
- }
-}
-
-
-OurBool
-IndexedFont_Kerned_Column :: bOpaque
-(
- LPDDSURFACEDESC lpDDSurfaceDesc,
- // assumes you have a read lock
- int x,
- int y
- // must be in range
-)
-{
- GLOBALASSERT(lpDDSurfaceDesc);
-
- void* pSurface = lpDDSurfaceDesc -> lpSurface;
-
- GLOBALASSERT(pSurface);
-
- int BytesPerPixel = lpDDSurfaceDesc -> ddpfPixelFormat . dwRGBBitCount /8;
-
- int BytesPerRow =
- (
- lpDDSurfaceDesc -> lPitch
- );
-
- int Pixel =
- (
- *(int*)
- (
- ((char*)pSurface)
- +
- ( y * BytesPerRow )
- +
- ( x * BytesPerPixel)
- )
- );
-
- return (Pixel != 0 );
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/tallfont.hpp b/3dc/avp/support/tallfont.hpp
deleted file mode 100644
index d8008a8..0000000
--- a/3dc/avp/support/tallfont.hpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
-
- tallfont.hpp
-
-*/
-
-#ifndef _tallfont
-#define _tallfont 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
-
- #ifdef __cplusplus
- #ifndef _indexfnt
- #include "indexfnt.hpp"
- #endif
- #endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-#ifdef __cplusplus
- // A new way of handling proportionally-spaced fonts: artists prepare
- // a tall thin bitmap containing all the characters, with a constant
- // height. Loader needs to know this height, and extracts character
- // widths using transparency information.
- class IndexedFont_Proportional_Column : public IndexedFont_Proportional
- {
- enum { MAX_CHARS_IN_TALLFONT = 100 };
-
- public:
- void RenderChar_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- void RenderChar_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- OurBool bCanRender( ProjChar ProjCh_In ) const
- {
- unsigned int offsetTemp;
- return GetOffset
- (
- offsetTemp,
- ProjCh_In
- );
- }
-
- int GetMaxWidth(void) const;
- int GetWidth
- (
- ProjChar ProjCh
- ) const;
- int GetHeight(void) const
- {
- return HeightPerChar_Val;
- }
-
- static IndexedFont_Proportional_Column* Create
- (
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
- );
-
- ~IndexedFont_Proportional_Column();
-
- private:
- IndexedFont_Proportional_Column
- (
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
- );
-
- int HeightPerChar_Val;
- int SpaceWidth_Val;
-
- LPDIRECTDRAWSURFACE image_ptr;
- AW_BACKUPTEXTUREHANDLE hBackup;
-
- r2size R2Size_OverallImage;
-
- int ASCIICodeForOffset0;
- int NumChars;
- RECT WindowsRectForOffset[ MAX_CHARS_IN_TALLFONT ];
- // coordinates of characters in the image
- int WidthForOffset[ MAX_CHARS_IN_TALLFONT ];
-
- private:
- int SpaceWidth(void) const
- {
- return SpaceWidth_Val;
- }
-
- void UpdateWidths(void);
- // called by constructor
- void SetWidth(unsigned int Offset, int newWidth)
- {
- WindowsRectForOffset[ Offset ] . right = newWidth;
- WidthForOffset[ Offset ] = newWidth;
- }
-
- static OurBool bAnyNonTransparentPixelsInColumn
- (
- r2pos R2Pos_TopOfColumn,
- int HeightOfColumn,
- LPDDSURFACEDESC lpDDSurfaceDesc
- // assumes you have a read lock
- );
-
- OurBool GetOffset
- (
- unsigned int& outputOffset,
- ProjChar inProjCh
- ) const
- {
- if (inProjCh < ASCIICodeForOffset0 )
- {
- return No;
- }
-
- outputOffset = (inProjCh - ASCIICodeForOffset0);
-
- if (outputOffset >= NumChars)
- {
- return No;
- }
-
- return Yes;
-
- }
- };
-
- // 3/4/98 DHM: A new implementation, supporting character kerning
- class IndexedFont_Kerned_Column : public IndexedFont_Kerned
- {
- enum { MAX_CHARS_IN_TALLFONT = 255 };
- // note that we define an array of ints sized this squared
- // so for 100, this works out as 100*100*4bytes
- // which is 40,000 bytes, or about 39k
-
- public:
- void RenderChar_Clipped
- (
- struct r2pos& R2Pos_Cursor,
- const struct r2rect& R2Rect_Clip,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- void RenderChar_Unclipped
- (
- struct r2pos& R2Pos_Cursor,
- int FixP_Alpha,
- ProjChar ProjCh
- ) const;
-
- OurBool bCanRender( ProjChar ProjCh_In ) const
- {
- unsigned int offsetTemp;
- return GetOffset
- (
- offsetTemp,
- ProjCh_In
- );
- }
-
- int GetMaxWidth(void) const;
- int GetWidth
- (
- ProjChar ProjCh
- ) const;
- int GetHeight(void) const
- {
- return HeightPerChar_Val;
- }
-
- int GetXInc
- (
- ProjChar currentProjCh,
- ProjChar nextProjCh
- ) const;
-
- static IndexedFont_Kerned_Column* Create
- (
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
- );
-
- ~IndexedFont_Kerned_Column();
-
- int FullWidthForOffset[ MAX_CHARS_IN_TALLFONT ];
-
- LPDIRECTDRAWSURFACE GetImagePtr(void) const
- {
- return (LPDIRECTDRAWSURFACE) image_ptr;
- }
- LPDIRECTDRAWSURFACE image_ptr;
- private:
- IndexedFont_Kerned_Column
- (
- FontIndex I_Font_New,
- char* Filename,
- int HeightPerChar_New,
- int SpaceWidth_New,
- int ASCIICodeForInitialCharacter
- );
-
- int HeightPerChar_Val;
- int SpaceWidth_Val;
-
- AW_BACKUPTEXTUREHANDLE hBackup;
-
- r2size R2Size_OverallImage;
-
- int ASCIICodeForOffset0;
- int NumChars;
- RECT WindowsRectForOffset[ MAX_CHARS_IN_TALLFONT ];
- // coordinates of characters in the image
- int XIncForOffset[ MAX_CHARS_IN_TALLFONT ][ MAX_CHARS_IN_TALLFONT ];
-
- private:
- int SpaceWidth(void) const
- {
- return SpaceWidth_Val;
- }
-
- void UpdateWidths(void);
- void UpdateXIncs(void);
- // called by constructor
-
- void SetWidth(unsigned int Offset, int newWidth)
- {
- WindowsRectForOffset[ Offset ] . right = newWidth;
- FullWidthForOffset[ Offset ] = newWidth;
- }
-
- static OurBool bAnyNonTransparentPixelsInColumn
- (
- r2pos R2Pos_TopOfColumn,
- int HeightOfColumn,
- LPDDSURFACEDESC lpDDSurfaceDesc
- // assumes you have a read lock
- );
-
- OurBool GetOffset
- (
- unsigned int& outputOffset,
- ProjChar inProjCh
- ) const
- {
- if (inProjCh < ASCIICodeForOffset0 )
- {
- return No;
- }
-
- outputOffset = (inProjCh - ASCIICodeForOffset0);
-
- if (outputOffset >= NumChars)
- {
- return No;
- }
-
- return Yes;
-
- }
-
- int CalcXInc
- (
- unsigned int currentOffset,
- unsigned int nextOffset,
- int* minOpaqueX,
- int* maxOpaqueX
- );
-
- OurBool OverlapOnRow
- (
- unsigned int currentOffset,
- unsigned int nextOffset,
- int Row,
- int ProposedXInc
- );
-
- int GetSmallestXIncForRow
- (
- unsigned int currentOffset,
- unsigned int nextOffset,
- int* minOpaqueX,
- int* maxOpaqueX,
- unsigned int Row
- );
-
- OurBool bOpaque
- (
- LPDDSURFACEDESC lpDDSurfaceDesc,
- // assumes you have a read lock
- int x,
- int y
- // must be in range
- );
-
- };
-
-#endif
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/trig666.cpp b/3dc/avp/support/trig666.cpp
deleted file mode 100644
index 30d0372..0000000
--- a/3dc/avp/support/trig666.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: trig666.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 18/11/97 from Headhunter's TRIGGERS.CPP; had to
- * rename to avoid conflict with AVP file TRIGGERS.H
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "trig666.hpp"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// class TriggerDaemon : public Daemon
-TriggerDaemon :: TriggerDaemon
-(
- OurBool fActive
-) : Daemon
- (
- fActive
- )
-{
-}
-
-TriggerDaemon :: ~TriggerDaemon()
-{
-}
-
-// A daemon which fires at regular intervals (potentially more than once per frame)
-// class PulsingTriggerDaemon : public TriggerDaemon
-PulsingTriggerDaemon :: PulsingTriggerDaemon
-(
- OurBool fActive,
- int FixP_Period // interval between triggers in seconds
-) : TriggerDaemon
- (
- fActive
- )
-{
- GLOBALASSERT( FixP_Period > 0);
-
- FixP_Period_Val = FixP_Period;
- FixP_TimeToNextPulse = FixP_Period;
-}
-
-PulsingTriggerDaemon :: ~PulsingTriggerDaemon()
-{
-}
-
-ACTIVITY_RETURN_TYPE PulsingTriggerDaemon :: Activity(ACTIVITY_INPUT)
-{
- while ( FixP_Time > 0 )
- {
- if ( FixP_Time >= FixP_TimeToNextPulse )
- {
- // then elapse some of the available time to take you to the pulse
- FixP_Time -= FixP_TimeToNextPulse;
- FixP_TimeToNextPulse = FixP_Period_Val;
-
- // and trigger:
- Triggered();
- }
- else
- {
- // Not enough time to warrant triggering; reduce time
- // to next pulse and stop.
- FixP_TimeToNextPulse -= FixP_Time;
- ACTIVITY_RVAL_NOCHANGE
- }
- }
-
- ACTIVITY_RVAL_NOCHANGE
-}
-
-void PulsingTriggerDaemon :: SetFuse_FixP
-(
- int FixP_Fuse // time until it next triggers; doesn't change the period
-)
-{
- GLOBALASSERT( FixP_Fuse > 0 );
- FixP_TimeToNextPulse = FixP_Fuse;
-}
-
-// A countdown daemon which DESTROYS ITSELF after it triggers
-// class CountdownDaemon : public TriggerDaemon
-CountdownDaemon :: CountdownDaemon
-(
- OurBool fActive,
- int FixP_Fuse // time until it triggers
-) : TriggerDaemon
- (
- fActive
- )
-{
- GLOBALASSERT( FixP_Fuse > 0 );
-
- FixP_TimeRemaining = FixP_Fuse;
-}
-
-CountdownDaemon :: ~CountdownDaemon()
-{
-}
-
-ACTIVITY_RETURN_TYPE CountdownDaemon :: Activity(ACTIVITY_INPUT)
-{
- #if 0
- textprint
- (
- "CountdownDaemon :: Activity(%i) with fuse %i\n",
- FixP_Time,
- FixP_TimeRemaining
- );
- #endif
-
- if ( FixP_TimeRemaining > FixP_Time )
- {
- // Keep counting down:
- FixP_TimeRemaining -= FixP_Time;
- }
- else
- {
- // Countdown has elapsed:
- Triggered();
- delete this;
- }
-
- ACTIVITY_RVAL_NOCHANGE
-}
-
-void CountdownDaemon :: SetFuse_FixP
-(
- int FixP_Fuse // time until it triggers
-)
-{
- FixP_TimeRemaining = FixP_Fuse;
-}
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/trig666.hpp b/3dc/avp/support/trig666.hpp
deleted file mode 100644
index f965943..0000000
--- a/3dc/avp/support/trig666.hpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-
- trig666.hpp
-
-*/
-
-#ifndef _trig666
-#define _trig666 1
-
- #ifndef _daemon
- #include "daemon.h"
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
- class TriggerDaemon : public Daemon
- {
- public:
- TriggerDaemon
- (
- OurBool fActive
- );
- ~TriggerDaemon();
- virtual void Triggered(void) = 0;
- // called by the daemon's activity whenever the daemon decides to
- // trigger it.
- private:
-
- };
-
- // A daemon which fires at regular intervals (potentially more than once per frame)
- class PulsingTriggerDaemon : public TriggerDaemon
- {
- public:
- PulsingTriggerDaemon
- (
- OurBool fActive,
- int FixP_Period // interval between triggers in seconds
- );
-
- ~PulsingTriggerDaemon();
-
- ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT);
- // never causes callback hooks to fire
-
- void SetFuse_FixP
- (
- int FixP_Fuse // time until it next triggers; doesn't change the period
- );
-
- // void Triggered(void) remains pure virtual
- private:
- int FixP_Period_Val;
- int FixP_TimeToNextPulse;
- };
-
- // A countdown daemon which DESTROYS ITSELF after it triggers
- class CountdownDaemon : public TriggerDaemon
- {
- public:
- CountdownDaemon
- (
- OurBool fActive,
- int FixP_Fuse // time until it triggers
- );
-
- ~CountdownDaemon();
-
- ACTIVITY_RETURN_TYPE Activity(ACTIVITY_INPUT);
- // never causes callback hooks to fire
-
- void SetFuse_FixP
- (
- int FixP_Fuse // time until it triggers
- );
-
- // void Triggered(void) remains pure virtual
- private:
- int FixP_TimeRemaining;
- };
-
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
-
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif
diff --git a/3dc/avp/support/vssver.scc b/3dc/avp/support/vssver.scc
deleted file mode 100644
index 56e2581..0000000
--- a/3dc/avp/support/vssver.scc
+++ /dev/null
Binary files differ
diff --git a/3dc/avp/support/wrapstr.cpp b/3dc/avp/support/wrapstr.cpp
deleted file mode 100644
index 2676c90..0000000
--- a/3dc/avp/support/wrapstr.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/*******************************************************************
- *
- * DESCRIPTION: wrapstr.cpp
- *
- * AUTHOR: David Malcolm
- *
- * HISTORY: Created 6/8/98
- *
- *******************************************************************/
-
-/* Includes ********************************************************/
-#include "3dc.h"
-#include "wrapstr.hpp"
-#include "strutil.h"
-
- #define UseLocalAssert Yes
- #include "ourasert.h"
-
-/* Version settings ************************************************/
-
-/* Constants *******************************************************/
-
-/* Macros **********************************************************/
-
-/* Imported function prototypes ************************************/
-
-/* Imported data ***************************************************/
-#ifdef __cplusplus
- extern "C"
- {
-#endif
- #if 0
- extern OurBool DaveDebugOn;
- extern FDIEXTENSIONTAG FDIET_Dummy;
- extern IFEXTENSIONTAG IFET_Dummy;
- extern FDIQUAD FDIQuad_WholeScreen;
- extern FDIPOS FDIPos_Origin;
- extern FDIPOS FDIPos_ScreenCentre;
- extern IFOBJECTLOCATION IFObjLoc_Origin;
- extern UncompressedGlobalPlotAtomID UGPAID_StandardNull;
- extern IFCOLOUR IFColour_Dummy;
- extern IFVECTOR IFVec_Zero;
- #endif
-#ifdef __cplusplus
- };
-#endif
-
-
-
-/* Exported globals ************************************************/
-
-/* Internal type definitions ***************************************/
-
-/* Internal function prototypes ************************************/
-
-/* Internal globals ************************************************/
-
-/* Exported function definitions ***********************************/
-// namespace WordWrap
-List<SCString*>* WordWrap :: DeprecatedMake
-(
- const SCString& SCString_In,
-
- const IndexedFont& IndexedFnt_In,
-
- int W_FirstLine_In,
- int W_Subsequently_In
- // widths to wrap with.
- // They are different in order to support paragraph starts of various kinds
- // e.g. bulleting
-)
-{
- GLOBALASSERT( W_FirstLine_In >= 0 );
- GLOBALASSERT( W_Subsequently_In >= 0 );
-
- // The list to return is initially empty:
- List<SCString*>* pList_pSCString_Return = new List<SCString*>;
-
- #if 1
- {
- // Iterate through the string:
- ProjChar* pProjCh_I = SCString_In . pProjCh();
-
- ProjChar* pProjCh_StartOfLine = pProjCh_I;
- int CharsInLine = 0;
-
- ProjChar* pProjCh_StartOfNextLine = 0;
- int CharsInLine_Good = 0;
- // update this whenever you have a "good" wrap position i.e.
- // one where there's whitespace
-
- int W_Available = W_FirstLine_In;
-
- while
- (
- !STRUTIL_SC_fIsTerminator
- (
- pProjCh_I
- )
- )
- {
- // Determine if adding this character to the line being
- // formed will make the line too long to fit:
- if
- (
- IndexedFnt_In . CalcSize
- (
- pProjCh_StartOfLine,
- ( CharsInLine + 1 )
- ) . w
- >
- W_Available
- )
- {
- // It won't fit:
- if ( CharsInLine_Good > 0 )
- {
- GLOBALASSERT( pProjCh_StartOfNextLine );
-
- // If so, flush the current line by creating a new SCString
- // for it and start a new line with this as the first character
- pList_pSCString_Return -> add_entry_end
- (
- new SCString
- (
- pProjCh_StartOfLine,
- CharsInLine_Good
- )
- );
-
- pProjCh_StartOfLine = pProjCh_StartOfNextLine;
- CharsInLine = (CharsInLine - CharsInLine_Good );
- CharsInLine_Good = 0;
- // Note that we don't advance pProjCh_I, but the variant does
- // decrease since pProjCh_StartOfLine will advance, reducing the number
- // of characters left to add.
-
- W_Available = W_Subsequently_In;
-
- continue;
- }
- else
- {
- // Emergency: what we have won't fit even by itself in the given
- // width. Continue processing until you reach a "good" breaking point:
- }
- }
-
- // Otherwise, add this character to the line being formed:
- {
- if
- (
- bWhitespace( *pProjCh_I )
- )
- {
- // Whitespace character:
- if
- (
- (CharsInLine == 0)
- )
- {
- // Ignore leading whitespace in a line:
- pProjCh_StartOfLine++;
- pProjCh_I++;
- }
- else
- {
- // Add this character to the line being generated; it is an acceptable
- // breaking point:
- pProjCh_I++;
- CharsInLine++;
-
- CharsInLine_Good = CharsInLine;
- pProjCh_StartOfNextLine = pProjCh_I;
- }
- }
- else if (*pProjCh_I=='\n')
- {
- pProjCh_I++;
- CharsInLine++;
-
- CharsInLine_Good = CharsInLine;
- pProjCh_StartOfNextLine = pProjCh_I;
-
- pList_pSCString_Return -> add_entry_end
- (
- new SCString
- (
- pProjCh_StartOfLine,
- CharsInLine_Good
- )
- );
-
- pProjCh_StartOfLine = pProjCh_StartOfNextLine;
- CharsInLine = (CharsInLine - CharsInLine_Good );
- CharsInLine_Good = 0;
- W_Available = W_Subsequently_In;
-
-
- }
- else
- {
- // Non-whitespace character:
-
- // Add this character to the line being generated; it is not an acceptable
- // breaking point:
- CharsInLine++;
- pProjCh_I++;
- }
- }
- }
-
- // Flush the final line that was formed:
- pList_pSCString_Return -> add_entry_end
- (
- new SCString
- (
- pProjCh_StartOfLine,
- CharsInLine
- )
- );
-
-
- }
- #else
- {
- // Iterate through the string:
- ProjChar* pProjCh_I = SCString_In . pProjCh();
- ProjChar* pProjCh_StartOfLine = pProjCh_I;
-
- int CharsInLine = 0;
-
- int W_Available = W_FirstLine_In;
-
- while
- (
- !STRUTIL_SC_fIsTerminator
- (
- pProjCh_I
- )
- )
- {
- // Determine if adding this character to the line being
- // formed will make the line too long to fit:
- if
- (
- IndexedFnt_In . CalcSize
- (
- pProjCh_StartOfLine,
- ( CharsInLine + 1 )
- ) . w
- >
- W_Available
- )
- {
- // It won't fit:
- if ( CharsInLine > 0 )
- {
- // If so, flush the current line by creating a new SCString
- // for it and start a new line with this as the first character
- pList_pSCString_Return -> add_entry_end
- (
- new SCString
- (
- pProjCh_StartOfLine,
- CharsInLine
- )
- );
-
- pProjCh_StartOfLine = pProjCh_I;
- CharsInLine = 0;
- // Note that we don't advance pProjCh_I, but the variant does
- // decrease since pProjCh_StartOfLine will advance, reducing the number
- // of characters left to add.
-
- W_Available = W_Subsequently_In;
- }
- else
- {
- // Emergency: the character we have won't fit even by itself in the given
- // width. Make a line containing just this character (to avoid infinite loops):
- pList_pSCString_Return -> add_entry_end
- (
- new SCString
- (
- pProjCh_StartOfLine,
- 1
- )
- );
-
- pProjCh_I++;
-
- pProjCh_StartOfLine = pProjCh_I;
- CharsInLine = 0;
-
- W_Available = W_Subsequently_In;
- }
- }
- else
- {
- // Otherwise, add this character to the line being formed:
- if
- (
- (CharsInLine == 0)
- &&
- bWhitespace( *pProjCh_I )
- )
- {
- // Ignore leading whitespace in a line:
- pProjCh_StartOfLine++;
- }
- else
- {
- // Add this character to the line being generated:
- CharsInLine ++;
- }
-
- pProjCh_I++;
-
- }
- }
-
- // Flush the final line that was formed:
- pList_pSCString_Return -> add_entry_end
- (
- new SCString
- (
- pProjCh_StartOfLine,
- CharsInLine
- )
- );
-
-
- }
- #endif
-
- return pList_pSCString_Return;
-}
-
-int WordWrap :: bWhitespace( ProjChar ProjCh )
-{
- // LOCALISEME();
- return ( ProjCh == ' ');
-}
-
-int WordWrap :: bWithinWord( ProjChar* pProjCh_Test )
-{
- GLOBALASSERT( pProjCh_Test );
-
- if ( bWhitespace(*pProjCh_Test) )
- {
- return No;
- }
-
- GLOBALASSERT
- (
- !STRUTIL_SC_fIsTerminator
- (
- pProjCh_Test
- )
- );
-
- return
- (
- !bWhitespace( *(pProjCh_Test++) )
- );
- // i.e you're within a word iff
- // neither you nor the next char are whitespace
-}
-
-
-/* Internal function definitions ***********************************/
diff --git a/3dc/avp/support/wrapstr.hpp b/3dc/avp/support/wrapstr.hpp
deleted file mode 100644
index 4070149..0000000
--- a/3dc/avp/support/wrapstr.hpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-
- wrapstr.hpp
-
- Support for word-wrapping strings: the heart of it takes a string,
- a font, and a width, and creates a list of strings objects guaranteed
- to have width less than or equal to the specified width when displayed with
- the specified font.
-
- This guarantee is not absolute; it can fail to be upheld if there's a word
- in the string that's wider than the width you give it (and thus can't fit
- without being broken)
-
- There is no support for mixing fonts.
-
- There is no support for carriage returns, tabs, etc.
-
-*/
-
-#ifndef _wrapstr_hpp
-#define _wrapstr_hpp 1
-
- #if ( defined( __WATCOMC__ ) || defined( _MSC_VER ) )
- #pragma once
- #endif
-
- #ifndef _scstring
- #include "scstring.hpp"
- #endif
-
- #ifndef _indexfnt
- #include "indexfnt.hpp"
- #endif
-
- #ifndef _reflist_hpp
- #include "reflist.hpp"
- #endif
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Version settings *****************************************************/
-
-/* Constants ***********************************************************/
-
-/* Macros ***************************************************************/
-
-/* Type definitions *****************************************************/
-
-/* Exported globals *****************************************************/
-
-/* Function prototypes **************************************************/
- namespace WordWrap
- {
- /* Deprecated version; to be phased out once we have interators for RefLists
- since you have to manually release references as you destroy all/parts of the list
- */
- extern List<SCString*>* DeprecatedMake
- (
- const SCString& SCString_In,
-
- const IndexedFont& IndexedFnt_In,
-
- int W_FirstLine_In,
- int W_Subsequently_In
- // widths to wrap with.
- // They are different in order to support paragraph starts of various kinds
- // e.g. bulleting
- );
-
- extern RefList<SCString>* Make
- (
- const SCString& SCString_In,
-
- const IndexedFont& IndexedFnt_In,
-
- int W_FirstLine_In,
- int W_Subsequently_In
- // widths to wrap with.
- // They are different in order to support paragraph starts of various kinds
- // e.g. bulleting
- );
-
- int bWhitespace( ProjChar ProjCh );
-
- int bWithinWord( ProjChar* pProjCh_Test );
-
- };
-
-
-/* End of the header ****************************************************/
-
-
-#ifdef __cplusplus
- };
-#endif
-
-#endif