コード例 #1
0
Ang3 CCinematicInput::UpdateAdditiveCameraInputWithController( const SUpdateContext& updateCtx, const Ang3& rawControllerInput )
{
	if (updateCtx.m_recenter)
	{
		Ang3 finalControllerAnglesLimited = rawControllerInput;

		//Yaw angle (Z axis)
		finalControllerAnglesLimited.z = -clamp_tpl((float)fsel(finalControllerAnglesLimited.z, finalControllerAnglesLimited.z * updateCtx.m_lookRightLimit, finalControllerAnglesLimited.z * updateCtx.m_lookLeftLimit), -updateCtx.m_lookLeftLimit, updateCtx.m_lookRightLimit);		

		//Pitch angle (X axis)
		finalControllerAnglesLimited.x *= (g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f;
		finalControllerAnglesLimited.x = clamp_tpl((float)fsel(finalControllerAnglesLimited.x, finalControllerAnglesLimited.x * updateCtx.m_lookUpLimit, finalControllerAnglesLimited.x * updateCtx.m_lookDownLimit), -updateCtx.m_lookDownLimit, updateCtx.m_lookUpLimit);

		//No roll allowed
		finalControllerAnglesLimited.y = 0.0f;

		Interpolate(m_controllerAccumulatedAngles, finalControllerAnglesLimited, 2.5f, updateCtx.m_frameTime);
	}
	else
	{
		Ang3 finalControllerAnglesLimited = m_controllerAccumulatedAngles;

		finalControllerAnglesLimited.x += ( (rawControllerInput.x * updateCtx.m_frameTime * 1.5f) * ((g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f) );
		finalControllerAnglesLimited.z -= (rawControllerInput.z * updateCtx.m_frameTime * 1.5f);

		finalControllerAnglesLimited.x = clamp_tpl(finalControllerAnglesLimited.x, -updateCtx.m_lookDownLimit, updateCtx.m_lookUpLimit);
		finalControllerAnglesLimited.z = clamp_tpl(finalControllerAnglesLimited.z, -updateCtx.m_lookLeftLimit, updateCtx.m_lookRightLimit);

		finalControllerAnglesLimited.y = 0.0f;

		m_controllerAccumulatedAngles = finalControllerAnglesLimited;
	}

	return m_controllerAccumulatedAngles;
}
コード例 #2
0
ファイル: PRT_COMP.C プロジェクト: daemqn/Atari_ST_Sources
/* ---------------- */
main()
{
    char path2[80];
    long code_len;

    appl_init();

    path1[0] = Dgetdrv();
    path1[1] = ':';
    Dgetpath(path1 + 2, path1[0] + 1);
    path1[0] += 'A';
    strcat(path1, "\\*.PRT");

    code_len = (long)Malloc(-1L) - 75000;
    code_mem = (unsigned char *)Malloc(code_len);

    graf_mouse(ARROW, 0L);

    do
    {
        if (!fsel(path1, "PRT", "Druckersource w�hlen!"))
            break;

        strcpy(path2, path1);
        if (rindex(path2, '.') > rindex(path2, '\\'))
            strcpy(rindex(path2, '.'), ".PRC");

        if (fsel(path2, "PRC", "Treiberdatei w�hlen!"))
            comp_source(path1, path2);

    } while(TRUE);

    appl_exit();
}
コード例 #3
0
ファイル: filedlg.cpp プロジェクト: gahr/fxite
long FileDlg::onToggleMulti(FXObject*o,FXSelector sel,void*p)
{
  setSelectMode(p?SELECTFILE_MULTIPLE:SELECTFILE_EXISTING);
  fsel()->txtfld()->setText(FXString::null);
  fsel()->fbox()->killSelection(true);
  if (p) {
    fsel()->fbox()->setFocus();
    fsel()->fbox()->setCurrentItem(0);
  } else {
    fsel()->txtfld()->setFocus();
  }
  return 1;
}
コード例 #4
0
//------------------------------------------------------------------------------------
// Adjust the aim dir before we pass it to the torsoAim pose modifier, this allows us
// to have the weapon deviate from the camera in certain circumstances
// Should only be called once per frame as it time-steps internal vars
//------------------------------------------------------------------------------------
void CLocalPlayerComponent::AdjustTorsoAimDir(float fFrameTime, Vec3 &aimDir)
{
	const f32 HALF_PI = gf_PI * 0.5f;
	float newElevLimit = HALF_PI;

	const f32 MIN_FLATTEN_LEVEL		= -0.3f;
	const f32 MAX_FLATTEN_LEVEL		= -0.1f;
	const f32 TARGET_FLATTEN_ELEV	= -0.2f;
	const f32 LIMIT_CHANGE_RATE		= HALF_PI;

	if (g_pGameCVars->pl_swimAlignArmsToSurface && m_rPlayer.IsSwimming() && (m_rPlayer.m_playerStateSwim_WaterTestProxy.GetRelativeWaterLevel() > MIN_FLATTEN_LEVEL))
	{
		newElevLimit = (m_rPlayer.m_playerStateSwim_WaterTestProxy.GetRelativeWaterLevel() - MIN_FLATTEN_LEVEL) / (MAX_FLATTEN_LEVEL - MIN_FLATTEN_LEVEL);
		newElevLimit = LERP(gf_PI * 0.5f, TARGET_FLATTEN_ELEV, clamp_tpl(newElevLimit, 0.0f, 1.0f));
	}

	float limitDelta = LIMIT_CHANGE_RATE * fFrameTime;
	float limitDiff	 = newElevLimit - m_stapElevLimit;
	float smoothedLimit = (float) fsel(fabs_tpl(limitDiff) - limitDelta, m_stapElevLimit + (fsgnf(limitDiff) * limitDelta), newElevLimit);
	m_stapElevLimit = smoothedLimit;

	if (smoothedLimit < HALF_PI)
	{
		//--- Need to limit, convert to yaw & elev, limit & then convert back
		float yaw, elev;
		float xy = aimDir.GetLengthSquared2D();
		if (xy > 0.001f)
		{
			yaw = atan2_tpl(aimDir.y,aimDir.x);
			elev = asin_tpl(clamp_tpl(aimDir.z, -1.f, +1.f));
		}
		else
		{
			yaw = 0.f;
			elev = (float)fsel(aimDir.z, +1.f, -1.f) * (gf_PI*0.5f);
		}

		elev = min(elev, smoothedLimit);

		float sinYaw, cosYaw;
		float sinElev, cosElev;

		sincos_tpl(yaw, &sinYaw, &cosYaw);
		sincos_tpl(elev, &sinElev, &cosElev);

		aimDir.x = cosYaw * cosElev;
		aimDir.y = sinYaw * cosElev;
		aimDir.z = sinElev;
	}
}
コード例 #5
0
ファイル: filedlg.cpp プロジェクト: gahr/fxite
void FileDlg::create()
{
  FXFileDialog::create();
  switch (getSelectMode()) {
    case SELECTFILE_ANY: {
      fsel()->txtfld()->setFocus();
      break;
    }
    case SELECTFILE_MULTIPLE: {
      fsel()->fbox()->setFocus();
      fsel()->fbox()->setCurrentItem(0);
      break;
    }
  }
}
コード例 #6
0
ファイル: video_options.cpp プロジェクト: albinoz/raine
static int choose_shader(int sel) {
    // This part is a little tricky because I want the fileselector when I
    // select this, but I don't want the whole path to be displayed, just
    // the filename selected alone. Tricky, but not long... !
    /* Something prevents glsl shaders from working. Tried to convert them from
     * cg shaders, got an error about "must write to gl_Position" when linking.
     * So they are disabled for now */
    char *exts[] = { "*.shader","*.glsl", NULL };
    char *dir,old[FILENAME_MAX];
    dir = get_shared("shaders");
    strcpy(old,ogl.shader);
    if (!strcmp(ogl.shader,"None"))
	*ogl.shader = 0;
    else {
	strcpy(dir,ogl.shader);
	char *p = strrchr(dir,SLASH[0]);
	if (p) *p = 0;
    }
    fsel(dir,exts,ogl.shader,"Select shader");
    if (ogl.shader[strlen(ogl.shader)-1] == SLASH[0] &&
	    strcmp(old,"None")) { // cancelled ?
	if (MessageBox(_("Confirmation"),_("Disable shaders ?"),_("Yes|No")) == 1)
	    strcpy(ogl.shader,"None");
	else
	    strcpy(ogl.shader,old);
    } else {
	ogl.render = 1;
    }
    preinit_ogl_options();
    return 0;
}
コード例 #7
0
ファイル: filedlg.cpp プロジェクト: gahr/fxite
void FileDlg::setSelectMode(FXuint mode) {
  FXFileDialog::setSelectMode(mode);
  if (multi_btn->shown()) {
    FXString label_text;
    if ( mode == SELECTFILE_MULTIPLE ) {
      fsel()->ToggleMulti(true);
      multi_btn->setState(true);
      multi_btn->setBackColor(getApp()->getSelbackColor());
      multi_btn->setTextColor(getApp()->getSelforeColor());
    } else {
      fsel()->ToggleMulti(false);
      multi_btn->setState(false);
      multi_btn->setBackColor(getApp()->getBackColor());
      multi_btn->setTextColor(getApp()->getForeColor());
    }
  }
}
コード例 #8
0
float CMountedGunController::CalculateAnimationTime(float aimRad)
{
	const float ANIM_ANGLE_RANGE = gf_PI*0.25f;

	float time = fmod_tpl(aimRad / ANIM_ANGLE_RANGE, 1.0f);
	time = (float)fsel(time, time, 1.0f + time);

	return time;
}
コード例 #9
0
void EntityEffects::CHeatController::AddHeatPulse( const float intensity, const float time )
{
	const float currentPulseHeat = (float)fsel(-m_heatPulse.baseTime, 
		0.0f, 
		clamp_tpl((1.0f - (m_heatPulse.runningTime * (float)fres(m_heatPulse.baseTime + FLT_EPSILON))) * m_heatPulse.heat, 0.0f, 1.0f));
	m_heatPulse.heat = clamp_tpl(currentPulseHeat + intensity, 0.0f, 1.0f - m_baseHeat);
	m_heatPulse.baseTime = clamp_tpl((m_heatPulse.baseTime - m_heatPulse.runningTime) + time, 0.0f, 4.5f);	//Fixed to maximum of 4.5secs to cool down
	m_heatPulse.runningTime = 0.0f;
}
コード例 #10
0
float EntityEffects::CHeatController::UpdateCoolDown(const float frameTime)
{
	const float cooldownRate = 0.075f;

	m_baseHeat = clamp_tpl(m_baseHeat - (frameTime * cooldownRate), 0.0f, m_baseHeat);
	m_coolDownHeat = (float)fsel(-(m_baseHeat - m_coolDownHeat), -1.0f, m_coolDownHeat);

	return m_baseHeat;
}
コード例 #11
0
ファイル: MT_FONT.C プロジェクト: daemqn/Atari_ST_Sources
/* ---------------------------- */
int load_font(int font_nr)
{
register int f_handle;
register long len;
register fontform *fnt_mem, *search;

if (fsel(font_path, ".FNT"))
	return(load_font_in(font_path, font_nr));
}
コード例 #12
0
ファイル: filedlg.cpp プロジェクト: gahr/fxite
FileDlg::FileDlg(FXWindow*win, const FXString&caption, bool optmulti):FXFileDialog(win,caption)
{
#ifdef WIN32
  filenames=NULL;
#endif
  ((FileSel*)filebox)->icobtn()->hide();
  multi_btn=new FXToggleButton( fsel()->nav(),_(" &M "),_(" &M "),NULL,NULL,this,
                                  ID_TOGGLE_MULTI,TOGGLEBUTTON_TOOLBAR|FRAME_RAISED );
  multi_btn->setTipText(_("Enable selection of multiple files"));
  multi_btn->setAltTipText(_("Enable manual entry of filename"));
  if (!optmulti) { multi_btn->hide(); }
}
コード例 #13
0
void CASW_Sentry_Top::CheckFiring()
{
	if ( gpGlobals->curtime > m_fNextFireTime && HasAmmo() && ( m_bHasHysteresis || m_hEnemy.Get() ) )
	{
		float flDist = fabs(m_fGoalYaw - m_fCurrentYaw);
		flDist = fsel( flDist - 180, 360 - flDist, flDist );

		if ( (flDist < ASW_SENTRY_FIRE_ANGLE_THRESHOLD) || ( m_bHasHysteresis && !m_hEnemy ) )
		{
			Fire();
		}	
	}
}
コード例 #14
0
Ang3 CCinematicInput::UpdateAdditiveCameraInputWithMouse( const SUpdateContext& updateCtx, const Ang3& rawMouseInput )
{
#if CINEMATIC_INPUT_PC_MOUSE
	Ang3 rawMouseInputModified = rawMouseInput * updateCtx.m_frameTime * updateCtx.m_frameTime;
	rawMouseInputModified.z = -rawMouseInputModified.z;
	rawMouseInputModified.x *= (g_pGameCVars->cl_invertMouse == 0) ? 1.0f : -1.0f;

	m_mouseAccumulatedInput += rawMouseInputModified;
	m_mouseAccumulatedInput.x = clamp_tpl(m_mouseAccumulatedInput.x, -1.0f, 1.0f);
	m_mouseAccumulatedInput.z = clamp_tpl(m_mouseAccumulatedInput.z, -1.0f, 1.0f);
	m_mouseAccumulatedInput.y = 0.0f;

	//Yaw angle (Z axis)
	m_mouseAccumulatedAngles.z = -(float)fsel(m_mouseAccumulatedInput.z, m_mouseAccumulatedInput.z * updateCtx.m_lookRightLimit, m_mouseAccumulatedInput.z * updateCtx.m_lookLeftLimit);		

	//Pitch angle (X axis)
	m_mouseAccumulatedAngles.x = (float)fsel(m_mouseAccumulatedInput.x, m_mouseAccumulatedInput.x * updateCtx.m_lookUpLimit, m_mouseAccumulatedInput.x * updateCtx.m_lookDownLimit);

	// Recenter after a certain amount of time without input
	if (updateCtx.m_recenter)
	{
		const float rawInputLen = fabs(rawMouseInputModified.x) + fabs(rawMouseInputModified.z);
		const float newRecenterTimeOut = (float)fsel(-rawInputLen, m_mouseRecenterTimeOut - updateCtx.m_frameTime, CINEMATIC_INPUT_MOUSE_RECENTER_TIMEOUT);
		if (newRecenterTimeOut < 0.0f)
		{
			Interpolate(m_mouseAccumulatedInput, Ang3(0.0f, 0.0f, 0.0f), 1.5f, updateCtx.m_frameTime);
		}

		m_mouseRecenterTimeOut = max(newRecenterTimeOut, 0.0f);
	}

	return m_mouseAccumulatedAngles;
#else
	return Ang3(0.0f, 0.0f, 0.0f);
#endif
	
}
コード例 #15
0
ファイル: TRANSFER.C プロジェクト: daemqn/Atari_ST_Sources
datei_empfangen(void)
{
int hd;

    if (fsel("*.*",tbuf,"Datei empfangen") == 1) {
        strcpy((char *)transfer[UEBERSCH].ob_spec,"Datei empfangen");
/*        v_gtext(handle,640-13*8,13,"E");*/
        open_dial(1);
		if ((hd=Fcreate(tbuf,0)) > 0) {
            show_msg(receive_xmodem(hd));
            Fclose(hd);
        }
        open_dial(0);
    }
}
コード例 #16
0
ファイル: TRANSFER.C プロジェクト: daemqn/Atari_ST_Sources
datei_senden(void)
{
int hd;

    if (fsel("*.*",tbuf,"Datei senden") == 1){
        strcpy((char *)transfer[UEBERSCH].ob_spec,"Datei senden");
/*        v_gtext(handle,640-13*8,13,"S");*/
        open_dial(1);
        if ((hd=Fopen(tbuf,0)) > 0) {
            show_msg(send_xmodem(hd));
            Fclose(hd);
        }
        open_dial(0);
    }
}
コード例 #17
0
ファイル: TRANSFER.C プロジェクト: daemqn/Atari_ST_Sources
send_ascii()
{
int c;
int hd;

    if (fsel("*.*",tbuf,"ASCII-Datei senden") == 1){
        if ((hd=Fopen(tbuf,0)) > 0) {
            while (Fread(hd,1L,&c)) {
                send(c>>8);
                if (Cconis())
                    if ((Crawcin()&255) == CAN)
                        return(-1);
            }
            Fclose(hd);
        }
    }
}
コード例 #18
0
ファイル: asw_rocket.cpp プロジェクト: docfinorlias/asb2
void	CASW_Rocket::ComputeWallDodge( const Vector &vCurVel )
{
	// trace to see if I'll hit a wall in the next second
	trace_t tr;
	UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + ( vCurVel * 0.8f ), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
	if ( tr.fraction < 1.0f )
	{
		// find a vector perpendicular to the wall
		Vector perp = tr.plane.normal.Cross( Vector(0,0,1) );
		Vector antiperp = -perp;

		// figure out whether to turn left or right!
		if ( antiperp.Dot(vCurVel) > perp.Dot(vCurVel) )
		{
			perp = antiperp;
		}

		// push the direction a little further away from the wall
		perp += fsel( vCurVel.Dot(tr.plane.normal) , -0.1f , 0.1f ) * tr.plane.normal;

		// work out new angles based on this direction
		VectorAngles( perp, m_vWobbleAngles );
	}
}
コード例 #19
0
void CMountedGunController::Update(EntityId mountedGunID, float frameTime)
{
	CRY_ASSERT_MESSAGE(m_pControlledPlayer, "Controlled player not initialized");

	CItem* pMountedGun = static_cast<CItem*>(gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(mountedGunID));

	bool canUpdateMountedGun = (pMountedGun != NULL) && (pMountedGun->GetStats().mounted);

	if (canUpdateMountedGun)
	{
		IMovementController * pMovementController = m_pControlledPlayer->GetMovementController();
		assert(pMovementController);

		SMovementState info;
		pMovementController->GetMovementState(info);

		IEntity* pMountedGunEntity = pMountedGun->GetEntity();
		const Matrix34& lastMountedGunWorldTM = pMountedGunEntity->GetWorldTM();

		Vec3 desiredAimDirection = info.aimDirection.GetNormalized();

		// AI can switch directions too fast, prevent snapping
		if(!m_pControlledPlayer->IsPlayer())
		{
			const Vec3 currentDir = lastMountedGunWorldTM.GetColumn1();
			const float dot = clamp_tpl(currentDir.Dot(desiredAimDirection), -1.0f, 1.0f);
			const float reqAngle = acos_tpl(dot);
			const float maxRotSpeed = 2.0f;
			const float maxAngle = frameTime * maxRotSpeed;
			if(fabs(reqAngle) > maxAngle)
			{
				const Vec3 axis = currentDir.Cross(desiredAimDirection);
				if(axis.GetLengthSquared() > 0.001f) // current dir and new dir are enough different
				{
					desiredAimDirection = currentDir.GetRotated(axis.GetNormalized(),sgn(reqAngle)*maxAngle);
				}
			}
		}				
		
		bool isUserClient = m_pControlledPlayer->IsClient();
		
		IEntity* pMountedGunParentEntity = pMountedGunEntity->GetParent();
		IVehicle *pVehicle = NULL;
		if(pMountedGunParentEntity && m_pControlledPlayer)
			pVehicle = m_pControlledPlayer->GetLinkedVehicle();

		CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem();

		//For client update always, for others only when there is notable change
		if (!pVehicle && (isUserClient || (!desiredAimDirection.IsEquivalent(lastMountedGunWorldTM.GetColumn1(), 0.003f)))) 
		{
			Quat rotation = Quat::CreateRotationVDir(desiredAimDirection, 0.0f);
			pMountedGunEntity->SetRotation(rotation);

			if (isUserClient && pRecordingSystem)
			{
				// Only record the gun position if you're using the gun.
				pRecordingSystem->OnMountedGunRotate(pMountedGunEntity, rotation);
			}
		}

		const Vec3 vInitialAimDirection = GetMountDirection(pMountedGun, pMountedGunParentEntity);
		assert( vInitialAimDirection.IsUnit() );

		//Adjust gunner position and animations
		UpdateGunnerLocation(pMountedGun, pMountedGunParentEntity, vInitialAimDirection);

		const float aimrad = Ang3::CreateRadZ(Vec2(vInitialAimDirection),Vec2(-desiredAimDirection));
		const float pitchLimit = sin_tpl(DEG2RAD(30.0f));
		const float animHeight = fabs_tpl(clamp_tpl(desiredAimDirection.z * (float)fres(pitchLimit), -1.0f, 1.0f));

		const float aimUp = (float)fsel(-desiredAimDirection.z, 0.0f, animHeight); 
		const float aimDown = (float)fsel(desiredAimDirection.z, 0.0f, animHeight);

		if (pRecordingSystem)
		{
			pRecordingSystem->OnMountedGunUpdate(m_pControlledPlayer, aimrad, aimUp, aimDown);
		}

		if(!m_pControlledPlayer->IsThirdPerson())
		{
			UpdateFirstPersonAnimations(pMountedGun, desiredAimDirection);
		}

		if(m_pMovementAction)
		{
			const float aimUpParam = aimUp;
			const float aimDownParam = aimDown;
			const float aimMovementParam = CalculateAnimationTime(aimrad);

			m_pMovementAction->SetParam(MountedGunCRCs.aimUpParam, aimUpParam);
			m_pMovementAction->SetParam(MountedGunCRCs.aimDownParam, aimDownParam);
			m_pMovementAction->SetParam(MountedGunCRCs.aimMovementParam, aimMovementParam);
		}

		UpdateIKMounted(pMountedGun);
	}
}
//==============>>> myCmdWindow::WindowCommand <<<================
  void myCmdWindow::WindowCommand(ItemVal id, ItemVal val,
	CmdType cType)
  {
    // route all commands through here - menus and buttons

    static char* filter[] = {"*.drw","*", 0};	// file filter
    static int fi = 0;
    vNoticeDialog note(this);	// for user notification

    switch (id)		// switch on id of commands
      {
	case M_New:
	  {
	    // call our NewAppWin method
	    theApp->NewAppWin(0,"V Draw - No Name",500,250,0);
	    break;
	  }

	case M_Open:
	  {
	    if (*_fname)
	      {
		note.Notice("Create a New window first.");
		break;
	      }

            vFileSelect fsel(this);     // V file select dialog

            if (!fsel.FileSelect("Open V Draw File",
	      _fname,99,filter,fi) || !*_fname)
		break;			// ignore if no selection

	    if (!myCanvas->Read(_fname))	// Save in _fname
	      {
		note.Notice("Unable to read file");
		break;
	      }
	    SetTitle(_fname);		// show on title bar
	    myCanvas->Redraw(0,0,0,0);	// paint it
	    break;
	  }

	case M_Save:
	  {
	    if (*_fname)			// have a name
	      {
		if (!myCanvas->Save(_fname))	// Save in _fname
		    note.Notice("Unable to save file");
		break;
	      }
	    // else fall through to SaveAs
	  }

	case M_SaveAs:
	  {
            vFileSelect fsel(this);     // V file select dialog

            if (!fsel.FileSelectSave("Save V Draw File As",
	      _fname,99,filter,fi) || !*_fname)
		break;			// ignore if no selection

	    if (!myCanvas->Save(_fname))	// Save in _fname
	      {
		note.Notice("Unable to read file");
		break;
	      }
	    SetTitle(_fname);
	    break;
	  }

	case M_Exit:
	  {
	    theApp->Exit();	// Standard action for Exit
	    break;
	  }

	case m_LineWidth:
	  {
	    _pen.SetWidth(val);	// set new pen width
	    myCanvas->SetPen(_pen);
	    break;
	  }

	case m_Clear:			// clear the screen
	  {
	    myCanvas->Clear();
	    break;
	  }

	default:			// change pen color?
	  {
	    if (id >= M_Black && id <= M_White)  // color button
	      {
		_pen.SetColor(vStdColors[val]);
		myCanvas->SetPen(_pen);
		SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().r(),Red);
		SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().g(),Green);
		SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().b(),Blue);
	      }
	    else		// pass up hierarchy
		vCmdWindow::WindowCommand(id, val, cType);
	    break;
	  }
      }
  }
コード例 #21
0
ファイル: TRANSFER.C プロジェクト: daemqn/Atari_ST_Sources
do_batch(void)
{
int hd,sec,hd2;
char line[80],*l;
long timer;

    if (fsel("*.TTB",tbuf,"Batch starten") == 1){
        if ((hd=Fopen(tbuf,0)) > 0) {
            while (readline(hd,line)){
                l=line;
                while (*l++ > 32);
                *(l-1)=0;
                strupr(line);
                if (!strcmp(line,"DIAL")) {
                    if (call_modem(-1,l)) break;
                    else continue;
                }
                if (!strcmp(line,"WAIT")) {
                    sec=atoi(l);
                    timer=get_timer();
                    while ((get_timer()-timer) < (sec*200))
                        evnt_timer(0,0);
                    continue;
                }
                if (!strcmp(line,"RWAIT")) {
                    if (rwait(l) == 0) continue;
                    else break;
                }
                if (!strcmp(line,"SEND")) {
                    while(*l) send(*l++);
                    send(13);
                    continue;
                }
                if (!strcmp(line,"END")) {
                    break;
                }
                if (!strcmp(line,"BAUDRATE")) {
                    continue;
                }
                if (!strcmp(line,"UPLOAD")) {
                    if (*l == 'X') {
                        para.blklen=128;
                        para.chk=CHKSUM;
                    }
                    if (*l == 'Y') {
                        para.blklen=1024;
                        para.chk=CRC;
                    }
                    while (*l++ > 32);
                    *(l-1)=0;
                    open_dial(1);
                    if ((hd2=Fopen(l,0)) > 0) {
                        send_xmodem(hd2);
                        Fclose(hd2);
                    }
                    open_dial(0);
                }   
                if (!strcmp(line,"DOWNLOAD")) {
                    if (*l == 'X') {
                        para.blklen=128;
                        para.chk=CHKSUM;
                    }
                    if (*l == 'Y') {
                        para.blklen=1024;
                        para.chk=CRC;
                    }
                    while (*l++ > 32);
                    *(l-1)=0;
                    open_dial(1);
                    if ((hd2=Fcreate(l,0)) > 0) {
                        receive_xmodem(hd2);
                        Fclose(hd2);
                    }
                    open_dial(0);
                }   
            }
            Fclose(hd);
        }
    }
}
コード例 #22
0
ファイル: filedlg.cpp プロジェクト: gahr/fxite
// Make the F4 key behave like it does with some other "toolkits"
// where it drops down the directory selection panel.
// Also makes tab-key navigation feel a little more intuitive (at least for me.)
long FileDlg::onKeyPress(FXObject*o,FXSelector sel,void*p)
{
  FXEvent*ev=(FXEvent*)p;
  switch (ev->code) {
    case KEY_F4: {
#ifdef FOX_1_6
      fsel()->dbox()->btn()->handle(fsel()->dbox()->btn(),FXSEL(SEL_COMMAND,ID_POST),NULL);
#else
      fsel()->dbox()->btn()->showMenu(true);
#endif
      fsel()->dbox()->setFocus();
      fsel()->dbox()->pn()->getFirst()->setFocus();
      break;
    }
    case KEY_Escape: {
#ifdef FOX_1_6
      if (fsel()->dbox()->isPaneShown()) {
        fsel()->dbox()->btn()->handle(fsel()->dbox()->btn(),FXSEL(SEL_COMMAND,ID_UNPOST),NULL);
        return 1;
      }
#else
      if (fsel()->dbox()->btn()->isMenuShown()) {
        fsel()->dbox()->btn()->showMenu(false);
        return 1;
      }
#endif
      break;
    }
    case KEY_Return: {
#ifdef FOX_1_6
      if (fsel()->dbox()->isPaneShown()||fsel()->dbox()->fld()->hasFocus()) {
        fsel()->dbox()->btn()->handle(fsel()->dbox()->btn(),FXSEL(SEL_COMMAND,ID_UNPOST),NULL);
        setDirectory(fsel()->dbox()->getDirectory());
        return 1;
      }
#else
      if (fsel()->dbox()->btn()->isMenuShown()||fsel()->dbox()->fld()->hasFocus()) {
        fsel()->dbox()->btn()->showMenu(false);
        setDirectory(fsel()->dbox()->getDirectory());
        return 1;
      }
#endif
      break;
    }
    case KEY_Tab: {
      if (fsel()->dbox()->fld()->hasFocus()) {
        if (ev->state & SHIFTMASK) {
          fsel()->setFocus();
          fsel()->txtfld()->setFocus();
        } else {
          fsel()->dbox()->getNext()->getNext()->setFocus();
        }
        return 1;
      } else {
        if (multi_btn->hasFocus()||(multi_btn->getPrev()->hasFocus()&&!multi_btn->shown())) {
          fsel()->fbox()->setFocus();
          return 1;
        } else {
          if (fsel()->fbox()->hasFocus()) {
            fsel()->txtfld()->setFocus();
            return 1;
          } else {
            if (fsel()->cncl()->hasFocus()) {
              fsel()->dbox()->fld()->setFocus();
              return 1;
            }
          }
        }
      }
      break;
    }
    case KEY_ISO_Left_Tab: {
      if (ev->state & SHIFTMASK) {
        if (fsel()->dbox()->fld()->hasFocus()) {
          fsel()->cncl()->setFocus();
          return 1;
        } else {
          if (fsel()->fbox()->hasFocus()) {
            if (multi_btn->shown()) {
              multi_btn->setFocus();
            } else {
              multi_btn->getPrev()->setFocus();
            }
            return 1;
          }
        }
      }
      break;
    }
  }
  return FXFileDialog::handle(o,sel,p);
}