/**********************************************************************
 *<
	FILE: ctrl.cpp

	DESCRIPTION:   DLL implementation of some controllers

	CREATED BY: Rolf Berteig

	HISTORY: created 13 June 1995

 *>	Copyright (c) 1994, All Rights Reserved.
 **********************************************************************/

#include "ctrl.h"
#include "buildver.h"

HINSTANCE hInstance;
int controlsInit = FALSE;

/** public functions **/
BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) {
	hInstance = hinstDLL;

	if ( !controlsInit ) {
		controlsInit = TRUE;
		
		// jaguar controls
		InitCustomControls(hInstance);

#ifdef OLD3DCONTROLS
		// initialize 3D controls
		Ctl3dRegister(hinstDLL);
		Ctl3dAutoSubclass(hinstDLL);
#endif
		
		// initialize Chicago controls
		InitCommonControls();

		SetDefaultBoolController(GetBoolControlDesc());
		}

	switch(fdwReason) {
		case DLL_PROCESS_ATTACH:
			break;
		case DLL_THREAD_ATTACH:
			break;
		case DLL_THREAD_DETACH:
			break;
		case DLL_PROCESS_DETACH:
			break;
		}
	return(TRUE);
	}


//------------------------------------------------------
// This is the interface to Jaguar:
//------------------------------------------------------

__declspec( dllexport ) const TCHAR *
LibDescription() { return
 GetString(IDS_RB_DEFCONTROLLERS); }


#ifndef DESIGN_VER

/// MUST CHANGE THIS NUMBER WHEN ADD NEW CLASS
__declspec( dllexport ) int LibNumberClasses() {return 21;}

__declspec( dllexport ) ClassDesc*
LibClassDesc(int i) {
	switch(i) {
		case 0: return GetPathCtrlDesc();
		case 1: return GetEulerCtrlDesc();
		case 2: return GetFloatNoiseDesc();
		case 3: return GetExprPosCtrlDesc();
		case 4: return GetExprP3CtrlDesc();
		case 5: return GetExprFloatCtrlDesc();
		case 6:	return GetExprScaleCtrlDesc();
		case 7:	return GetPositionNoiseDesc();
		case 8: return GetPoint3NoiseDesc();
		case 9: return GetRotationNoiseDesc();
		case 10: return GetScaleNoiseDesc();
		case 11: return GetBoolControlDesc();
		case 12: return GetIPosCtrlDesc();
		case 13: return GetAttachControlDesc();
		case 14: return GetIPoint3CtrlDesc();
		case 15: return GetIColorCtrlDesc();
		case 16: return GetLinkCtrlDesc();
		case 17: return GetFollowUtilDesc();
		case 18: return GetSurfCtrlDesc();
		case 19: return GetLODControlDesc();
		case 20: return GetLODUtilDesc();

//		case 7: return GetExprRotCtrlDesc();
		default: return 0;
		}
	}

#else

/// MUST CHANGE THIS NUMBER WHEN ADD NEW CLASS
__declspec( dllexport ) int LibNumberClasses() { return 17; }

__declspec( dllexport ) ClassDesc*
LibClassDesc(int i) {
	switch(i) {
		case 0: return GetPathCtrlDesc();
		case 1: return GetEulerCtrlDesc();
		case 2: return GetFloatNoiseDesc();
//		case 3: return GetExprPosCtrlDesc();
//		case 4: return GetExprP3CtrlDesc();
//		case 5: return GetExprFloatCtrlDesc();
//		case 6:	return GetExprScaleCtrlDesc();
		case 3:	return GetPositionNoiseDesc();
		case 4: return GetPoint3NoiseDesc();
		case 5: return GetRotationNoiseDesc();
		case 6: return GetScaleNoiseDesc();
		case 7: return GetBoolControlDesc();
		case 8: return GetIPosCtrlDesc();
		case 9: return GetAttachControlDesc();
		case 10: return GetIPoint3CtrlDesc();
		case 11: return GetIColorCtrlDesc();
		case 12: return GetLinkCtrlDesc();
		case 13: return GetFollowUtilDesc();
		case 14: return GetSurfCtrlDesc();
		case 15: return GetLODControlDesc();
		case 16: return GetLODUtilDesc();

		default: return 0;
		}
	}

#endif


// Return version so can detect obsolete DLLs
__declspec( dllexport ) ULONG 
LibVersion() { return VERSION_3DSMAX; }

TCHAR *GetString(int id)
{
	static TCHAR buf[256];

	if(hInstance)
		return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL;
	return NULL;
}

