void __fastcall TKeysState::UnPressKey(unsigned short Key, Classes::TShiftState Shift) { int i = ExistKey(Key); if(i != -1) { delete KeysList->Items[i]; KeysList->Delete(i); } }
void KeysValues::CheckExistKey(CS& key) const { bool exist = ExistKey(key); if(not exist) { string msg ; msg += "Error: Key does not exi\n"; msg += "key is " + key; throw invalid_argument(msg); } }
void __fastcall TKeysState::PressKey(unsigned short Key, Classes::TShiftState Shift) { if(ExistKey(Key) == -1) { int i = KeysList->Add(new TKeyState); ((TKeyState*)KeysList->Items[i])->Key = Key; ((TKeyState*)KeysList->Items[i])->Shift = Shift; ((TKeyState*)KeysList->Items[i])->TimePress = ((TKeyState*)KeysList->Items[i])->TimePress.CurrentDateTime(); //Key = (unsigned short)i; } }
// возвращает битмаск из 'enum RegImportStyle' DWORD MRegistryBase::GetAllowedImportStyles() { DWORD nAllowed = 0; // ExistKey возвращает 0 - если ключ есть if (!ExistKey(HKEY__HIVE,0,0)) { // Допустим только импорт "по месту", импорт в корень - невозможен } else if (cfg->is64bitOs) { // ExistKey возвращает 0 - если ключ есть // Проверить, есть ли в reg-файле HKLM или HKCR if (ExistKey(HKEY_LOCAL_MACHINE,0,0) && ExistKey(HKEY_CLASSES_ROOT,0,0)) { // В этом случае (HKCU) импорт ведется без разницы 32/64 nAllowed = ris_Native; } else { if (ExistKey(HKEY_LOCAL_MACHINE, L"SOFTWARE", L"Wow6432Node") == 0) { // Допустим импорт только в 64битном режиме (это выгрузка 64битного ключа, раз он содержит Wow6432Node) nAllowed = ris_Import64; } else { nAllowed = ris_Native|ris_Import32|ris_Import64; } } } else { // x86 OS, различий веток реестра (32bit/64bit) нет вообще nAllowed = ris_Native; } return nAllowed; }
bool CAutoDerrick::EventProcess(const Event &event) { CObject* fret; Math::Vector pos, speed; Math::Point dim; float angle, duration, factor; CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; if ( event.type != EVENT_FRAME ) return true; if ( m_phase == ADP_WAIT ) return true; m_progress += event.rTime*m_speed; m_timeVirus -= event.rTime; if ( m_object->GetVirusMode() ) // contaminated by a virus? { if ( m_timeVirus <= 0.0f ) { m_timeVirus = 0.1f+Math::Rand()*0.3f; pos.x = 0.0f; pos.z = 0.0f; pos.y = -2.0f*Math::Rand(); m_object->SetPosition(1, pos); // up / down the drill m_object->SetAngleY(1, Math::Rand()*0.5f); // rotates the drill } return true; } if ( m_phase == ADP_EXCAVATE ) { if ( m_soundChannel == -1 ) { if ( m_type == OBJECT_URANIUM ) { factor = DERRICK_DELAYu/DERRICK_DELAY; } else { factor = 1.0f; } m_soundChannel = m_sound->Play(SOUND_DERRICK, m_object->GetPosition(0), 1.0f, 0.5f, true); m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.5f, 4.0f*factor, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.3f, 6.0f*factor, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.5f, 1.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.5f, 4.0f, SOPER_STOP); } if ( m_progress >= 6.0f/16.0f && // penetrates into the ground? m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { m_lastParticle = m_time; pos = m_object->GetPosition(0); speed.x = (Math::Rand()-0.5f)*10.0f; speed.z = (Math::Rand()-0.5f)*10.0f; speed.y = Math::Rand()*5.0f; dim.x = Math::Rand()*3.0f+2.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f); } if ( m_progress >= 6.0f/16.0f && // penetrates into the ground? m_lastTrack+m_engine->ParticleAdapt(0.5f) <= m_time ) { m_lastTrack = m_time; pos = m_object->GetPosition(0); speed.x = (Math::Rand()-0.5f)*12.0f; speed.z = (Math::Rand()-0.5f)*12.0f; speed.y = Math::Rand()*10.0f+10.0f; dim.x = 0.6f; dim.y = dim.x; pos.y += dim.y; duration = Math::Rand()*2.0f+2.0f; m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK5, duration, Math::Rand()*10.0f+15.0f, duration*0.2f, 1.0f); } if ( m_progress < 1.0f ) { pos.x = 0.0f; pos.z = 0.0f; pos.y = -m_progress*16.0f; m_object->SetPosition(1, pos); // down the drill angle = m_object->GetAngleY(1); angle += event.rTime*8.0f; m_object->SetAngleY(1, angle); // rotates the drill } else { m_phase = ADP_ASCEND; m_progress = 0.0f; m_speed = 1.0f/5.0f; } } if ( m_phase == ADP_ASCEND ) { if ( m_progress <= 7.0f/16.0f && m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time ) { m_lastParticle = m_time; pos = m_object->GetPosition(0); speed.x = (Math::Rand()-0.5f)*10.0f; speed.z = (Math::Rand()-0.5f)*10.0f; speed.y = Math::Rand()*5.0f; dim.x = Math::Rand()*3.0f+2.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f); } if ( m_progress <= 4.0f/16.0f && m_lastTrack+m_engine->ParticleAdapt(1.0f) <= m_time ) { m_lastTrack = m_time; pos = m_object->GetPosition(0); speed.x = (Math::Rand()-0.5f)*12.0f; speed.z = (Math::Rand()-0.5f)*12.0f; speed.y = Math::Rand()*10.0f+10.0f; dim.x = 0.6f; dim.y = dim.x; pos.y += dim.y; duration = Math::Rand()*2.0f+2.0f; m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK5, duration, Math::Rand()*10.0f+15.0f, duration*0.2f, 1.0f); } if ( m_progress < 1.0f ) { pos.x = 0.0f; pos.z = 0.0f; pos.y = -(1.0f-m_progress)*16.0f; m_object->SetPosition(1, pos); // back the drill angle = m_object->GetAngleY(1); angle -= event.rTime*2.0f; m_object->SetAngleY(1, angle); // rotates the drill } else { m_soundChannel = -1; m_bSoundFall = false; m_phase = ADP_EXPORT; m_progress = 0.0f; m_speed = 1.0f/5.0f; } } if ( m_phase == ADP_ISFREE ) { if ( m_progress >= 1.0f ) { m_bSoundFall = false; m_phase = ADP_EXPORT; m_progress = 0.0f; m_speed = 1.0f/5.0f; } } if ( m_phase == ADP_EXPORT ) { if ( m_progress == 0.0f ) { if ( SearchFree(m_fretPos) ) { angle = m_object->GetAngleY(0); CreateFret(m_fretPos, angle, m_type, 16.0f); } else { m_phase = ADP_ISFREE; m_progress = 0.0f; m_speed = 1.0f/2.0f; return true; } } fret = SearchFret(); if ( fret != 0 && m_progress <= 0.5f && m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time ) { m_lastParticle = m_time; if ( m_progress < 0.3f ) { pos = fret->GetPosition(0); pos.x += (Math::Rand()-0.5f)*5.0f; pos.z += (Math::Rand()-0.5f)*5.0f; pos.y += (Math::Rand()-0.5f)*5.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 3.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIRE, 1.0f, 0.0f, 0.0f); } else { pos = fret->GetPosition(0); pos.x += (Math::Rand()-0.5f)*5.0f; pos.z += (Math::Rand()-0.5f)*5.0f; pos.y += Math::Rand()*2.5f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 1.0f; dim.y = dim.x; m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f); } } if ( m_progress < 1.0f ) { if ( fret != 0 ) { pos = fret->GetPosition(0); pos.y -= event.rTime*20.0f; // grave if ( !m_bSoundFall && pos.y < m_fretPos.y ) { m_sound->Play(SOUND_BOUM, m_fretPos); m_bSoundFall = true; } if ( pos.y < m_fretPos.y ) { pos.y = m_fretPos.y; fret->SetLock(false); // object usable } fret->SetPosition(0, pos); } } else { if ( ExistKey() ) // key already exists? { m_phase = ADP_WAIT; m_progress = 0.0f; m_speed = 1.0f/10.0f; } else { m_phase = ADP_EXCAVATE; m_progress = 0.0f; m_speed = 1.0f/(m_type==OBJECT_URANIUM?DERRICK_DELAYu:DERRICK_DELAY); } } } return true; }