📄 info.cpp
字号:
/****************************************************
*
* Restrictions Information Window
* David Power (x4373)
* 2/2/98
*
*****************************************************/
#include <windows.h>
#include "f4version.h"
#include "targa.h"
#include "PlayerOp.h"
#include "chandler.h"
#include "ui95_ext.h"
#include "falcsess.h"
#include "falclib\include\f4find.h"
#include "userids.h"
#include "iconids.h"
#include "textids.h"
#include "Dispcfg.h"
#include "logbook.h"
#include "rules.h"
#include "uicomms.h"
extern C_Handler *gMainHandler;
void CloseWindowCB(long ID,short hittype,C_Base *control);
static void INFOSaveValues(void);
static void INFOSaveRules(void);
void CheckCompliance(void);
void AreYouSure(long TitleID,long MessageID,void (*OkCB)(long,short,C_Base*),void (*CancelCB)(long,short,C_Base*));
void AreYouSure(long TitleID,_TCHAR *text,void (*OkCB)(long,short,C_Base*),void (*CancelCB)(long,short,C_Base*));
extern int INFOLoaded;
RulesClass CurrRules;
void (*OkCB)() = NULL;
void (*CancelCB)() = NULL;
int modify = 0;
_TCHAR GameName[19] = "Uninitialized";
void INFOSetupRulesControls(void)
{
C_Window *win;
C_Button *button;
C_ListBox *lbox;
C_Slider *slider;
C_EditBox *ebox;
win=gMainHandler->FindWindow(INFO_WIN);
if(win == NULL)
return;
int host = modify;
//if(FalconLocalGame == vuPlayerPoolGroup)
//if(vuLocalSessionEntity->Game())
//host = TRUE;
//if this is true, we are the host
/*
if( FalconLocalGameEntity && FalconLocalSession &&
FalconLocalGameEntity->OwnerId() == FalconLocalSession->Id() )
host = TRUE;
else if(!gCommsMgr->GetTargetGame() && !FalconLocalGameEntity)
host = TRUE;
if(gCommsMgr->GetSettings()->Rules.GameStatus != GAME_WAITING)
host = FALSE;*/
ebox = (C_EditBox *)win->FindControl(INFO_GAMENAME);
if(ebox)
{
if(host)
ebox->SetFlagBitOn(C_BIT_ENABLED);
else
ebox->SetFlagBitOff(C_BIT_ENABLED);
// if(FalconLocalGame != vuPlayerPoolGroup)
// ebox->SetText(FalconLocalGameEntity->GameName());
// else
if(gCommsMgr->GetTargetGame())
ebox->SetText( gCommsMgr->GetTargetGame()->GameName() );
else
{
ebox->SetText(GameName);
}
ebox->Refresh();
}
ebox = (C_EditBox *)win->FindControl(MAX_PLAYERS);
if(ebox)
{
if(host)
ebox->SetFlagBitOn(C_BIT_ENABLED);
else
ebox->SetFlagBitOff(C_BIT_ENABLED);
ebox->SetInteger(CurrRules.MaxPlayers);
ebox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(FLTMOD_REQ);
if(lbox != NULL)
{
if(host)
lbox->SetFlagBitOn(C_BIT_ENABLED);
else
lbox->SetFlagBitOff(C_BIT_ENABLED);
if(CurrRules.GetFlightModelType()==FMAccurate)
lbox->SetValue(FLTMOD_1);
else
lbox->SetValue(FLTMOD_2);
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(RADAR_REQ);
if(lbox != NULL)
{
if(host)
lbox->SetFlagBitOn(C_BIT_ENABLED);
else
lbox->SetFlagBitOff(C_BIT_ENABLED);
switch(CurrRules.GetAvionicsType())
{
case ATRealistic:
lbox->SetValue(RADAR_1);
break;
case ATSimplified:
lbox->SetValue(RADAR_2);
break;
case ATEasy:
lbox->SetValue(RADAR_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(WEAPEFF_REQ);
if(lbox != NULL)
{
if(host)
lbox->SetFlagBitOn(C_BIT_ENABLED);
else
lbox->SetFlagBitOff(C_BIT_ENABLED);
switch(CurrRules.GetWeaponEffectiveness())
{
case WEAccurate:
lbox->SetValue(WEAPEFF_1);
break;
case WEEnhanced:
lbox->SetValue(WEAPEFF_2);
break;
case WEExaggerated:
lbox->SetValue(WEAPEFF_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(AUTOPILOT_REQ);
if(lbox != NULL)
{
if(host)
lbox->SetFlagBitOn(C_BIT_ENABLED);
else
lbox->SetFlagBitOff(C_BIT_ENABLED);
switch(CurrRules.GetAutopilotMode())
{
case APNormal:
lbox->SetValue(AUTO_1);
break;
case APEnhanced:
lbox->SetValue(AUTO_2);
break;
case APIntelligent:
lbox->SetValue(AUTO_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(REFUELING_REQ);
if(lbox != NULL)
{
if(host)
lbox->SetFlagBitOn(C_BIT_ENABLED);
else
lbox->SetFlagBitOff(C_BIT_ENABLED);
switch(CurrRules.GetRefuelingMode())
{
case ARRealistic:
lbox->SetValue(REFUEL_1);
break;
case ARModerated:
lbox->SetValue(REFUEL_2);
break;
case ARSimplistic:
lbox->SetValue(REFUEL_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(PADLOCK_REQ);
if(lbox != NULL)
{
if(host)
lbox->SetFlagBitOn(C_BIT_ENABLED);
else
lbox->SetFlagBitOff(C_BIT_ENABLED);
switch(CurrRules.GetPadlockMode())
{
case PDDisabled:
lbox->SetValue(PADLOCK_4);
break;
case PDRealistic:
lbox->SetValue(PADLOCK_1);
break;
case PDEnhanced:
lbox->SetValue(PADLOCK_2);
break;
//case PDSuper:
// lbox->SetValue(PADLOCK_3);
// break;
}
lbox->Refresh();
}
button=(C_Button *)win->FindControl(FUEL_REQ);
if(button != NULL)
{
if(CurrRules.UnlimitedFuel())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(CHAFFLARES_REQ);
if(button != NULL)
{
if(CurrRules.UnlimitedChaff())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(COLLISIONS_REQ);
if(button != NULL)
{
if(CurrRules.CollisionsOn())
button->SetState(C_STATE_0);
else
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)win->FindControl(BLACKOUT_REQ);
if(button != NULL)
{
if(CurrRules.BlackoutOn())
button->SetState(C_STATE_0);
else
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)win->FindControl(IDTAGS_REQ);
if(button != NULL)
{
if(CurrRules.NameTagsOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(WEATHER_REQ);
if(button != NULL)
{
if(CurrRules.WeatherOn())
button->SetState(C_STATE_0);
else
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)win->FindControl(INVULNERABILITY_REQ);
if(button != NULL)
{
if(CurrRules.InvulnerableOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(EXT_VIEWS_REQ);
if(button != NULL)
{
if(CurrRules.ExternalViewOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
slider=(C_Slider *)win->FindControl(VEHICLE_SIZE_REQ);
if(slider != NULL)
{
if(host)
slider->SetFlagBitOn(C_BIT_ENABLED);
else
slider->SetFlagBitOff(C_BIT_ENABLED);
slider->SetSliderPos(static_cast<long>((slider->GetSliderMax()-slider->GetSliderMin())*((CurrRules.ObjMagnification) - 1)/4.0f));
ebox = (C_EditBox *)win->FindControl(VEHICLE_SIZE_READOUT_REQ);
if(ebox)
{
ebox->SetInteger(static_cast<long>(CurrRules.ObjMagnification));
ebox->Refresh();
slider->SetUserNumber(0,VEHICLE_SIZE_READOUT_REQ);
}
}
win->RefreshWindow();
}
///this function sets up all the controls according to the values stored
///in the PlayerOptions structure
void INFOSetupControls(void)
{
C_Window *win;
C_Button *button;
C_ListBox *lbox;
C_Slider *slider;
C_EditBox *ebox;
win=gMainHandler->FindWindow(INFO_WIN);
if(win == NULL)
return;
button=(C_Button *)win->FindControl(INFO_COMPLY);
if(button != NULL)
{
if(PlayerOptions.InCompliance(CurrRules.GetRules()) )
{
button->SetLabel(0,TXT_OK);
}
else
{
button->SetLabel(0,TXT_COMPLY);
}
button->Refresh();
}
lbox=(C_ListBox *)win->FindControl(FLTMOD_CUR);
if(lbox != NULL)
{
if(PlayerOptions.GetFlightModelType()==FMAccurate)
lbox->SetValue(FLTMOD_1);
else
lbox->SetValue(FLTMOD_2);
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(RADAR_CUR);
if(lbox != NULL)
{
switch(PlayerOptions.GetAvionicsType())
{
case ATRealistic:
lbox->SetValue(RADAR_1);
break;
case ATSimplified:
lbox->SetValue(RADAR_2);
break;
case ATEasy:
lbox->SetValue(RADAR_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(WEAPEFF_CUR);
if(lbox != NULL)
{
switch(PlayerOptions.GetWeaponEffectiveness())
{
case WEAccurate:
lbox->SetValue(WEAPEFF_1);
break;
case WEEnhanced:
lbox->SetValue(WEAPEFF_2);
break;
case WEExaggerated:
lbox->SetValue(WEAPEFF_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(AUTOPILOT_CUR);
if(lbox != NULL)
{
switch(PlayerOptions.GetAutopilotMode())
{
case APNormal:
lbox->SetValue(AUTO_1);
break;
case APEnhanced:
lbox->SetValue(AUTO_2);
break;
case APIntelligent:
lbox->SetValue(AUTO_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(REFUELING_CUR);
if(lbox != NULL)
{
switch(PlayerOptions.GetRefuelingMode())
{
case ARRealistic:
lbox->SetValue(REFUEL_1);
break;
case ARModerated:
lbox->SetValue(REFUEL_2);
break;
case ARSimplistic:
lbox->SetValue(REFUEL_3);
break;
}
lbox->Refresh();
}
lbox=(C_ListBox *)win->FindControl(PADLOCK_CUR);
if(lbox != NULL)
{
switch(PlayerOptions.GetPadlockMode())
{
case PDDisabled:
lbox->SetValue(PADLOCK_4);
break;
case PDRealistic:
lbox->SetValue(PADLOCK_1);
break;
case PDEnhanced:
lbox->SetValue(PADLOCK_2);
break;
//case PDSuper:
// lbox->SetValue(PADLOCK_3);
// break;
}
lbox->Refresh();
}
button=(C_Button *)win->FindControl(FUEL_CUR);
if(button != NULL)
{
if(PlayerOptions.UnlimitedFuel())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(CHAFFLARES_CUR);
if(button != NULL)
{
if(PlayerOptions.UnlimitedChaff())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(COLLISIONS_CUR);
if(button != NULL)
{
if(PlayerOptions.CollisionsOn())
button->SetState(C_STATE_0);
else
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)win->FindControl(BLACKOUT_CUR);
if(button != NULL)
{
if(PlayerOptions.BlackoutOn())
button->SetState(C_STATE_0);
else
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)win->FindControl(IDTAGS_CUR);
if(button != NULL)
{
if(PlayerOptions.NameTagsOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)win->FindControl(WEATHER_CUR);
if(button != NULL)
{
if(PlayerOptions.WeatherOn())
button->SetState(C_STATE_0);
else
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)win->FindControl(INVULNERABILITY_CUR);
if(button != NULL)
{
if(PlayerOptions.InvulnerableOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
slider=(C_Slider *)win->FindControl(VEHICLE_SIZE_CUR);
if(slider != NULL)
{
slider->SetSliderPos(static_cast<long>((slider->GetSliderMax()-slider->GetSliderMin())*((PlayerOptions.ObjMagnification) - 1)/4));
ebox = (C_EditBox *)win->FindControl(VEHICLE_SIZE_READOUT_CUR);
if(ebox)
{
ebox->SetInteger(static_cast<short>(PlayerOptions.ObjMagnification));
ebox->Refresh();
slider->SetUserNumber(0,VEHICLE_SIZE_READOUT_CUR);
}
}
INFOSetupRulesControls();
CheckCompliance();
}
void UpdateRules(void)
{
if(VuLocalGame != vuPlayerPoolGroup)
CurrRules.LoadRules(FalconLocalGame->rules.GetRules());
if(!gMainHandler)
return;
INFOSetupRulesControls();
C_Window *win;
C_Button *button;
win=gMainHandler->FindWindow(INFO_WIN);
if(win == NULL)
return;
button=(C_Button *)win->FindControl(INFO_COMPLY);
if(button != NULL)
{
if(PlayerOptions.InCompliance(CurrRules.GetRules()) )
{
button->SetLabel(0,TXT_OK);
}
else
{
button->SetLabel(0,TXT_COMPLY);
}
button->Refresh();
}
}
void ComplyCB(long ID,short hittype,C_Base *control)
{
FalconGameEntity *game;
C_EditBox *ebox;
_TCHAR name[30];
_TCHAR *head,*tail;
if(hittype != C_TYPE_LMOUSEUP)
return;
game=(FalconGameEntity*)gCommsMgr->GetTargetGame();
ebox = (C_EditBox *)control->Parent_->FindControl(INFO_GAMENAME);
if(ebox)
{
if(ebox->GetText())
_tcscpy(name,ebox->GetText());
else
_tcscpy(name,GameName);
head=name;
while(*head && !_istalnum(*head))
head++;
tail=head;
while(*tail)
tail++;
while(tail != head && !_istalnum(*tail))
tail--;
tail++;
*tail=0;
if((tail-head) < (3*sizeof(_TCHAR)) || !(*head))
{
AreYouSure(TXT_ERROR,TXT_INVALID_GAMENAME,CloseWindowCB,CloseWindowCB);
return;
}
ebox->Refresh();
ebox->SetText(head);
ebox->Refresh();
}
INFOSaveValues();/*
if( PlayerOptions.InCompliance(CurrRules.GetRules()) )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -