2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/sound/vocore.cpp,v 1.3 2000/02/02 15:18:05 adurant Exp $
29 ////////////////////////////////////////////////////////////
30 // Voice over implementation classes
32 //------------------------------------------------------------
33 // cVoiceOverSys agg member implementation
36 class cVoiceOverSys
: public cCTDelegating
<IVoiceOverSys
>,
37 public cCTAggregateMemberControl
<kCTU_Default
>
40 static sRelativeConstraint gConstraints
[];
43 cVoiceOverSys(IUnknown
* pOuter
)
44 :mpInCombat(NULL
),mPlaying(SCH_HANDLE_NULL
)
46 MI_INIT_AGGREGATION_1(pOuter
,IVoiceOverSys
,kPriorityNormal
,gConstraints
);
54 //----------------------------------------
58 tVOTestFunc mpInCombat
;
61 IObjectSystem
* mpObjSys
;
64 //----------------------------------------
70 mpObjSys
= AppGetObj(IObjectSystem
);
71 mpQuest
= AppGetObj(IQuestData
);
77 SafeRelease(mpObjSys
);
82 //----------------------------------------
85 void OnSchema(int handle
, ObjID schema
)
87 if (handle
== mPlaying
)
88 mPlaying
= SCH_HANDLE_NULL
;
92 static void SchemaCB(int hSchema
, ObjID schemaID
, void* pdata
)
94 cVoiceOverSys
* us
= (cVoiceOverSys
*)pdata
;
95 us
->OnSchema(hSchema
,schemaID
);
98 inline cStr
SchemaVarName(ObjID schemaID
)
101 const char* name
= mpObjSys
->GetName(schemaID
);
103 sprintf(buf
,"SCHPLAY_%s",name
);
105 sprintf(buf
,"SCHPLAYID_%d",schemaID
);
110 //----------------------------------------
111 // IVoiceOverSys Methods
114 STDMETHOD_(int,Play
)(int schema
)
116 if (mPlaying
!= SCH_HANDLE_NULL
)
117 return SCH_HANDLE_NULL
;
119 sSchemaPlayParams
* params
= SchemaPlayParamsGet(schema
);
121 //Don't crash if it doesn't exist.
122 if (!params
) return SCH_HANDLE_NULL
;
124 if ((params
->flags
& SCH_PLAY_ONCE
) && AlreadyPlayed(schema
))
125 return SCH_HANDLE_NULL
;
127 if ((params
->flags
& SCH_NO_COMBAT
) && mpInCombat
&& mpInCombat())
128 return SCH_HANDLE_NULL
;
130 sSchemaCallParams call
= g_sDefaultSchemaCallParams
;
131 call
.flags
|= SCH_SET_CALLBACK
;
132 call
.callback
= SchemaCB
;
135 mPlaying
= SchemaIDPlay(schema
,&call
);
137 if (mPlaying
!= SCH_HANDLE_NULL
)
138 SetAlreadyPlayed(schema
,TRUE
);
143 STDMETHOD_(BOOL
,AlreadyPlayed
)(int schema
)
145 return mpQuest
->Get(SchemaVarName(schema
));
148 STDMETHOD(SetAlreadyPlayed
)(int schema
, BOOL played
)
150 cStr var
= SchemaVarName(schema
);
153 if (mpQuest
->Exists(var
))
154 mpQuest
->Set(var
,TRUE
);
156 mpQuest
->Create(var
,TRUE
,kQuestDataMission
);
159 mpQuest
->Delete(var
);
164 STDMETHOD(SetCombatTest
)(tVOTestFunc func
)
172 F_DECLARE_INTERFACE(IPropertyManager
);
175 sRelativeConstraint
cVoiceOverSys::gConstraints
[] =
177 { kConstrainAfter
, &IID_IPropertyManager
},
181 void VoiceOverCreate()
183 AutoAppIPtr(Unknown
);
184 cAutoIPtr
<IVoiceOverSys
> sys(new cVoiceOverSys(pUnknown
));