⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ui_setup.cpp

📁 空战游戏flacon源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************\
UI_setup.cpp
Dave Power (x4373)

  setup screen stuff for falcon
\***************************************************************************/

#include "falclib.h"
#include "chandler.h"
#include "userids.h"
#include "PlayerOp.h"
#include "sim\include\stdhdr.h"
#include "uicomms.h"
#include "Graphics\Include\render3d.h"
#include "Graphics\Include\renderow.h"
#include "Graphics\Include\drawBSP.h"
#include "Graphics\Include\matrix.h"
#include "objectiv.h"
#include "cbsplist.h"
#include "c3dview.h"
#include "ui_setup.h"
#include "Graphics\Include\RViewPnt.h"
#include <tchar.h>
#include "f4find.h"
#include "sim\include\inpFunc.h"
#include "dispopts.h"
#include "logbook.h"
#include "sim\include\sinput.h"
#include "sim\include\simio.h"
#include "cmusic.h"
#include "dispcfg.h"
#include "Graphics\Include\draw2d.h"
#include "falcsess.h"

extern int STPLoaded;
extern C_Handler *gMainHandler;
extern C_Parser *gMainParser;
extern char **KeyDescrips;  

extern C_3dViewer	*SetupViewer;
extern RViewPoint	*tmpVpoint;
extern ObjectPos	*Objects;
extern FeaturePos	*Features;
extern Drawable2D	*Smoke;

int GraphicSettingMult = 1;

long Cluster = 8001;
int ready = FALSE;
//JOYCAPS S_joycaps;
MMRESULT S_joyret;
F4CSECTIONHANDLE* SetupCritSection = NULL;

float JoyScale;
float RudderScale;
float ThrottleScale;

RECT Rudder;
RECT Throttle;
int Calibrated = FALSE;

//defined in this file
static void HookupSetupControls(long ID);
void STPSetupControls(void);
void SetupRadioCB(long ID,short hittype,C_Base *control);


//defined in another file
void CloseWindowCB(long ID,short hittype,C_Base *control);
void UI_Help_Guide_CB(long ID,short hittype,C_Base *ctrl);
void GenericTimerCB(long ID,short hittype,C_Base *control);
void OpenLogBookCB(long ID,short hittype,C_Base *control);
BOOL AddWordWrapTextToWindow(C_Window *win,short *x,short *y,short startcol,short endcol,COLORREF color,_TCHAR *str,long Client=0);
void INFOSetupControls(void);
void CheckFlyButton(void);

//SimTab.cpp
int GetRealism(C_Window *win);
int SetRealism(C_Window *win);
void SimControlCB(long ID,short hittype,C_Base *control);
void SetSkillCB(long ID,short hittype,C_Base *control);

//ControlsTab.cpp
SIM_INT CalibrateFile (void);
SIM_INT Calibrate ( void  );
void InitKeyDescrips(void);
void CleanupKeys(void);
void RefreshJoystickCB(long ID,short hittype,C_Base *control);
BOOL KeystrokeCB(unsigned char DKScanCode,unsigned char Ascii,unsigned char ShiftStates,long RepeatCount);
void CalibrateCB(long ID,short hittype,C_Base *control);
BOOL SaveKeyMapList( char *filename);
int UpdateKeyMapList( char *fname, int flag);
void StopCalibrating(C_Base *control);
void SetKeyDefaultCB(long ID,short hittype,C_Base *control);
int CreateKeyMapList(  char *filename);
void SaveKeyButtonCB(long ID,short hittype,C_Base *control);
void LoadKeyButtonCB(long ID,short hittype,C_Base *control);
void ControllerSelectCB(long ID,short hittype,C_Base *control);
void BuildControllerList(C_ListBox *lbox);
void HideKeyStatusLines(C_Window *win);
void RecenterJoystickCB(long ID,short hittype,C_Base *control);
void SetABDetentCB(long ID,short hittype,C_Base *control);

//GraphicsTab.cpp
void STPMoveRendererCB(C_Window *win);
void STPViewTimerCB(long ID,short hittype,C_Base *control);
void STPDisplayCB(long ID,short hittype,C_Base *control);
void SfxLevelCB(long ID,short hittype,C_Base *control);
void RenderViewCB(long ID,short hittype,C_Base *control);
void ChangeViewpointCB(long ID,short hittype,C_Base *control);
void GouraudCB(long ID,short hittype,C_Base *control);
void HazingCB(long ID,short hittype,C_Base *control);
void AlphaBlendCB(long ID,short hittype,C_Base *control);
void BilinearFilterCB(long ID,short hittype,C_Base *control);
void ObjectTextureCB(long ID,short hittype,C_Base *control);
void BuildingDetailCB(long ID,short hittype,C_Base *control);
void ObjectDetailCB(long ID,short hittype,C_Base *control);
void VehicleSizeCB(long ID,short hittype,C_Base *control);
void TerrainDetailCB(long ID,short hittype,C_Base *control);
void TextureDistanceCB(long ID,short hittype,C_Base *control);
void VideoCardCB(long ID,short hittype,C_Base *control);
void VideoDriverCB(long ID,short hittype,C_Base *control);
void ResolutionCB(long ID,short hittype,C_Base *control);
void BuildVideoCardList(C_ListBox *lbox);
void DisableEnableDrivers(C_ListBox *lbox);
void DisableEnableResolutions(C_ListBox *lbox);
void BuildVideoDriverList(C_ListBox *lbox);
void GraphicsDefaultsCB(long ID,short hittype,C_Base *control);
void ScalingCB(long ID,short hittype,C_Base *control);
void BuildResolutionList(C_ListBox *lbox);
void PlayerBubbleCB(long ID,short hittype,C_Base *control);


//SoundTab.cpp
void InitSoundSetup();
void TestButtonCB(long ID,short hittype,C_Base *control);
void SoundSliderCB(long ID,short hittype,C_Base *control);
void PlayVoicesCB(long ID,short hittype,C_Base *control);

void LoadSetupWindows()
{
	long		ID=0;
	int			size=0;
	C_Button	*ctrl=NULL;
	C_Window	*win=NULL;
	C_TimerHook *tmr=NULL;
	C_Line		*line=NULL;
	C_Bitmap	*bmap=NULL;
	UI95_RECT	client;
	
	//if setup is already loaded, we only need to make sure all the control
	//settings are up to date
	if(STPLoaded) 
	{
		STPSetupControls();
		if(KeyVar.NeedUpdate)
		{
			UpdateKeyMapList(PlayerOptions.keyfile,1);
			KeyVar.NeedUpdate = FALSE;
		}
		return;
	}
	
	//Do basic UI setup of window
	if( _LOAD_ART_RESOURCES_)
		gMainParser->LoadImageList("art\\st_res.lst");
	else
		gMainParser->LoadImageList("art\\st_art.lst");
	gMainParser->LoadSoundList("art\\st_snd.lst");
	gMainParser->LoadWindowList("art\\st_scf.lst");
	
	ID=gMainParser->GetFirstWindowLoaded();
	while(ID)
	{
		//Hookup the callbacks
		HookupSetupControls(ID);
		ID=gMainParser->GetNextWindowLoaded();
	}
	
	
	win=gMainHandler->FindWindow(SETUP_WIN);
	if(win != NULL)
	{
		//timer to update joystick bmp on controls tab
		tmr=new C_TimerHook;
		tmr->Setup(C_DONT_CARE,C_TYPE_TIMER);
		tmr->SetUpdateCallback(GenericTimerCB);
		tmr->SetRefreshCallback(RefreshJoystickCB);
		tmr->SetUserNumber(_UI95_TIMER_DELAY_,1); // Timer activates every 80 mseconds (Only when this window is open)
		tmr->SetCluster(8004);
		win->AddControl(tmr);
		
		//timer to update the view position on graphics tab
		tmr=new C_TimerHook;
		tmr->Setup(C_DONT_CARE,C_TYPE_TIMER);
		tmr->SetUpdateCallback(GenericTimerCB);
		tmr->SetRefreshCallback(ChangeViewpointCB);
		tmr->SetUserNumber(_UI95_TIMER_DELAY_,1); // Timer activates every 80 mseconds (Only when this window is open)
		tmr->SetCluster(8002);
		win->AddControl(tmr);

		//timer to generate new radio message calls on sound tab
		tmr=new C_TimerHook;
		tmr->Setup(C_DONT_CARE,C_TYPE_TIMER);
		tmr->SetUpdateCallback(GenericTimerCB);
		tmr->SetRefreshCallback(PlayVoicesCB);
		tmr->SetUserNumber(_UI95_TIMER_DELAY_,100); // Timer activates every 8 seconds (Only when this window is open)
		tmr->SetCluster(8003);
		win->AddControl(tmr);
		
		//make sure sim tab is selected the first time in
		ctrl=(C_Button *)win->FindControl(SIM_TAB);
		SetupRadioCB(SETUP_WIN,C_TYPE_LMOUSEUP,ctrl);
		
		bmap=(C_Bitmap *)win->FindControl(JOY_INDICATOR);
		if(bmap != NULL)
		{
			size = bmap->GetH() + 1;
		}
		
		//use joystick.dat to calibrate joystick
		//Calibration.calibrated = CalibrateFile();
		
		client = win->GetClientArea(1);
		
		//setup scale for manipulating joystick control on controls tab
		//if(Calibration.calibrated)
			JoyScale = (float)(client.right - client.left - size)/2.0F;
		//else
			//JoyScale = (float)(client.right - client.left - size)/65536.0F;
		
		//setup scale for manipulating rudder control on controls tab
		line=(C_Line *)win->FindControl(RUDDER);
		if(line != NULL)
		{
			if( !IO.AnalogIsUsed(3) )
				line->SetColor(RGB(130,130,130)); //grey
			//if(Calibration.calibrated)
				RudderScale = (line->GetH() )/2.0F;
			//else
				//RudderScale = (line->GetH() )/65536.0F;
			
			Rudder.left = line->GetX();
			Rudder.right = line->GetX() + line->GetW();
			Rudder.top = line->GetY();
			Rudder.bottom = line->GetY() + line->GetH();
		}
		
		//setup scale for manipulating throttle control on controls tab
		line=(C_Line *)win->FindControl(THROTTLE);
		if(line != NULL)
		{
			if( !IO.AnalogIsUsed(2) )
				line->SetColor(RGB(130,130,130)); //grey

			//if(Calibration.calibrated)
				ThrottleScale = (float)line->GetH();
			//else
				//ThrottleScale = (line->GetH())/65536.0F;
			
			Throttle.left = line->GetX();
			Throttle.right = line->GetX() + line->GetW();
			Throttle.top = line->GetY();
			Throttle.bottom = line->GetY() + line->GetH();
			
		}

				
	}
	
	InitKeyDescrips();
	//set all the controls to their correct positions according to the saved options file
	STPSetupControls();	
	
	CreateKeyMapList( PlayerOptions.keyfile);

	STPLoaded++;
}//LoadSetupWindows


void SetupOpenLogBookCB(long ID,short hittype,C_Base *control)
{
	if(hittype != C_TYPE_LMOUSEUP)
		return;

	InitSoundSetup();

	OpenLogBookCB(ID,hittype,control);
}

///this function sets up all the controls according to the values stored
///in the PlayerOptions structure
void STPSetupControls(void)
{
	C_Window	*win;
	C_Button	*button;
	C_Text		*text;
	C_ListBox	*lbox;
	C_Slider	*slider;
	C_EditBox	*ebox;
	
	win=gMainHandler->FindWindow(SETUP_WIN);
	
	if(win == NULL)
		return;
	
	lbox=(C_ListBox *)win->FindControl(SET_FLTMOD);
	if(lbox != NULL)
	{
		if(PlayerOptions.GetFlightModelType()==FMAccurate)
			lbox->SetValue(SET_FLTMOD_1);
		else
			lbox->SetValue(SET_FLTMOD_2);

		lbox->Refresh();
	}
	
	lbox=(C_ListBox *)win->FindControl(SET_RADAR);
	if(lbox != NULL)
	{
		switch(PlayerOptions.GetAvionicsType())
		{
		case ATRealistic:
			lbox->SetValue(SET_RADAR_1);
			break;
		case ATSimplified:
			lbox->SetValue(SET_RADAR_2);
			break;
		case ATEasy:
			lbox->SetValue(SET_RADAR_3);
			break;
		}
		lbox->Refresh();
	}
	
	lbox=(C_ListBox *)win->FindControl(SET_WEAPEFF);
	if(lbox != NULL)
	{
		switch(PlayerOptions.GetWeaponEffectiveness())
		{
		case WEAccurate:
			lbox->SetValue(SET_WEAPEFF_1);
			break;
		case WEEnhanced:
			lbox->SetValue(SET_WEAPEFF_2);
			break;
		case WEExaggerated:
			lbox->SetValue(SET_WEAPEFF_3);
			break;
		}
		lbox->Refresh();
	}
	
	lbox=(C_ListBox *)win->FindControl(SET_AUTOPILOT);
	if(lbox != NULL)
	{
		switch(PlayerOptions.GetAutopilotMode())
		{
		case APNormal:
			lbox->SetValue(SET_AUTO_1);
			break;
		case APEnhanced:
			lbox->SetValue(SET_AUTO_2);
			break;
		case APIntelligent:
			lbox->SetValue(SET_AUTO_3);
			break;
		}
		lbox->Refresh();
	}

	lbox=(C_ListBox *)win->FindControl(SET_REFUELING);
	if(lbox != NULL)
	{
		switch(PlayerOptions.GetRefuelingMode())
		{
		case ARRealistic:
			lbox->SetValue(SET_REFUEL_1);
			break;
		case ARModerated:
			lbox->SetValue(SET_REFUEL_2);
			break;
		case ARSimplistic:
			lbox->SetValue(SET_REFUEL_3);
			break;
		}
		lbox->Refresh();
	}

	lbox=(C_ListBox *)win->FindControl(SET_PADLOCK);
	if(lbox != NULL)
	{
		switch(PlayerOptions.GetPadlockMode())
		{
		case PDDisabled:
			lbox->SetValue(SET_PADLOCK_4);
			break;
		case PDRealistic:
			lbox->SetValue(SET_PADLOCK_1);
			break;
		case PDEnhanced:
			lbox->SetValue(SET_PADLOCK_2);
			break;
		//case PDSuper:
		//	lbox->SetValue(SET_PADLOCK_3);
		//	break;
		}
		lbox->Refresh();
	}

	lbox=(C_ListBox *)win->FindControl(SET_CANOPY_CUE);
	if(lbox != NULL)
	{
		switch(PlayerOptions.GetVisualCueMode())
		{
		case VCNone:
			lbox->SetValue(CUE_NONE);
			break;
		case VCLiftLine:
			lbox->SetValue(CUE_LIFT_LINE);
			break;
		case VCReflection:
			lbox->SetValue(CUE_REFLECTION_MAP);
			break;
		case VCBoth:
			lbox->SetValue(CUE_BOTH);
			break;
		}
		lbox->Refresh();
	}

	lbox=(C_ListBox *)win->FindControl(SET_VIDEO_DRIVER);
	if(lbox != NULL)
	{
		BuildVideoDriverList(lbox);

		DisableEnableDrivers(lbox);
		lbox->SetValue(DisplayOptions.DispVideoDriver + 1);
		lbox->Refresh();
	}

	lbox=(C_ListBox *)win->FindControl(SET_VIDEO_CARD);
	if(lbox != NULL)
	{
		BuildVideoCardList(lbox);

		lbox->SetValue(DisplayOptions.DispVideoCard + 1);
		lbox->Refresh();
	}
	
	lbox=(C_ListBox *)win->FindControl(SET_RESOLUTION);
	if(lbox != NULL)
	{
		BuildResolutionList(lbox);

		DisableEnableResolutions(lbox);
		lbox->SetValue( DisplayOptions.DispWidth ); 
		lbox->Refresh();
	}
	
	button=(C_Button *)win->FindControl(SET_LOGBOOK);
	if(button != NULL)
	{
		button->SetText(0,UI_logbk.Callsign());
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(SET_ORDNANCE);
	if(button != NULL)
	{
		if(PlayerOptions.UnlimitedAmmo())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(SET_FUEL);
	if(button != NULL)
	{
		if(PlayerOptions.UnlimitedFuel())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(SET_CHAFFLARES);
	if(button != NULL)
	{
		if(PlayerOptions.UnlimitedChaff())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
		
	}
	
	button=(C_Button *)win->FindControl(SET_COLLISIONS);
	if(button != NULL)
	{
		if(PlayerOptions.CollisionsOn())
			button->SetState(C_STATE_0);
		else
			button->SetState(C_STATE_1);
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(SET_BLACKOUT);
	if(button != NULL)
	{
		if(PlayerOptions.BlackoutOn())
			button->SetState(C_STATE_0);
		else
			button->SetState(C_STATE_1);
		button->Refresh();
	}
	
	
	button=(C_Button *)win->FindControl(SET_IDTAGS);
	if(button != NULL)
	{
		if(PlayerOptions.NameTagsOn())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(SET_WEATHER);
	if(button != NULL)
	{
		if(PlayerOptions.WeatherOn())
			button->SetState(C_STATE_0);
		else
			button->SetState(C_STATE_1);
		button->Refresh();
	}

	button=(C_Button *)win->FindControl(SET_BULLSEYE_CALLS);
	if(button != NULL)
	{
		if(PlayerOptions.BullseyeOn())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}

	button=(C_Button *)win->FindControl(SET_INVULNERABILITY); //should be SET_INVULNERABLITY
	if(button != NULL)
	{
		if(PlayerOptions.InvulnerableOn())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}
	
	ebox = (C_EditBox *)win->FindControl(ACMI_FILE_SIZE);
	if(ebox)
	{
		ebox->SetInteger( PlayerOptions.AcmiFileSize() );
		ebox->Refresh();
	}

	button=(C_Button *)win->FindControl(AUTO_SCALE);
	if(button != NULL)
	{
		if(PlayerOptions.ObjectDynScalingOn())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}

	button=(C_Button *)win->FindControl(GOUROUD);//GOUROUD
	if(button != NULL)
	{
		if(PlayerOptions.GouraudOn())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(HAZING);
	if(button != NULL)
	{
		if(PlayerOptions.HazingOn())
			button->SetState(C_STATE_1);
		else
			button->SetState(C_STATE_0);
		button->Refresh();
	}
	
	button=(C_Button *)win->FindControl(ALPHA_BLENDING);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -