bool ff::ViewWindow::Deactivate(bool hide) { assertRetVal(IsValid(), true); if (_active) { _active = false; #if !METRO_APP if (hide) { SetWindowPos(Handle(), HWND_TOP, RectInt(0, 0, 0, 0), SWP_HIDEWINDOW | SWP_NOOWNERZORDER); } if (_mainWindow != nullptr) { HWND child = GetChildWindow(); if (child && ff::IsAncestor(child, Handle())) { _mainWindow->HideSharedViewTarget(); } } #endif OnDeactivated(); } return true; }
ButtonUnit::ButtonUnit() { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | EFFECT_FADEIN | SMOOTH_LL; m_Alpha = 0.75f; setWindow( RectInt( PointInt(0,0), SizeInt( 32, 24 ) ) ); setEnable( false ); }
ButtonBuildStructure::ButtonBuildStructure() { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | EFFECT_FADEIN | SMOOTH_LL | LOCK_ICON_SIZE; m_Alpha = 0.75f; setWindow( RectInt( PointInt(0,0), SizeInt( 32, 24 ) ) ); setEnable( false ); }
ViewEngineering::ButtonGadget::ButtonGadget() { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | EFFECT_FADEIN | SMOOTH_LL | LOCK_ICON_SIZE; m_Alpha = 0.75f; setWindow( RectInt( PointInt(0,0), SizeInt( 32, 24 ) ) ); setEnable( false ); }
void Duck::initSki() { frames[DuckFrame::UP_1 ] = RectInt( 0, 386, 27, 422); frames[DuckFrame::UP_2 ] = RectInt( 35, 386, 66, 422); frames[DuckFrame::UP_3 ] = RectInt( 68, 386, 93, 424); frames[DuckFrame::NORM_1 ] = RectInt( 98, 392, 130, 421); frames[DuckFrame::NORM_2 ] = RectInt(136, 395, 168, 422); frames[DuckFrame::NORM_3 ] = RectInt(173, 393, 205, 424); frames[DuckFrame::SHOT ] = RectInt(212, 394, 243, 425); frames[DuckFrame::FALLING] = RectInt(245, 395, 263, 435); }
ButtonCargo::ButtonCargo() { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | EFFECT_FADEIN | SMOOTH_LL | SHOW_HOTKEY | LOCK_ICON_SIZE; m_Alpha = 0.75f; m_HotKey = 'U'; setWindow( RectInt( PointInt(0,0), CARGO_BUTTON_SIZE ) ); setEnable( false ); }
RasterVsVectorState::RasterVsVectorState() { //Sets up the raster circle (aka the circle with pixels). initSprite(rastercircle, sprites, RectInt(0, 16, 32, 48), 1, VectorFloat(SCREEN.GetWidth()/4, CENTER.y)); //Sets up the vector circle vectorcircle = Shape::Circle(Window.GetWidth()*.75, CENTER.y, 16, Color::Blue); //Sets the title text rastertitle.SetText("Raster Vs. Vector Graphics"); }
ButtonGadget::ButtonGadget() : m_bCursorOver( false ) { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | EFFECT_FADEIN | SMOOTH_LL; m_Alpha = 0.75f; m_IconColor = GREEN; setWindow( RectInt( PointInt(0,0), SizeInt( 32, 24 ) ) ); setEnable( false ); }
ButtonContact::ButtonContact() : m_IsObjective( false ), m_bGroupLeader( false ), m_bGroupPending( false ) { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | SMOOTH_LL | EFFECT_FADEIN; m_Alpha = 0.75f; setWindow( RectInt( PointInt(0,0), SizeInt( BUTTON_WIDTH, BUTTON_HEIGHT ) ) ); }
ButtonContact::ButtonContact( NodeWindow * pParent, Noun * pNoun ) : m_IsObjective( false ), m_bGroupLeader( false ), m_bGroupPending( false ) { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | SMOOTH_LL | EFFECT_FADEIN; m_Alpha = 0.75f; setWindow( RectInt( PointInt(0,0), SizeInt( BUTTON_WIDTH, BUTTON_HEIGHT ) ) ); // attach this button to the parent pParent->attachNode( this ); // set this button setButton( pNoun ); }
Duck::Duck() { frames[DuckFrame::UP_1 ] = RectInt( 0, 197, 29, 229); frames[DuckFrame::UP_2 ] = RectInt( 35, 197, 64, 229); frames[DuckFrame::UP_3 ] = RectInt( 67, 197, 96, 229); frames[DuckFrame::NORM_1 ] = RectInt( 98, 198, 132, 229); frames[DuckFrame::NORM_2 ] = RectInt(136, 199, 170, 230); frames[DuckFrame::NORM_3 ] = RectInt(173, 198, 206, 229); frames[DuckFrame::SHOT ] = RectInt(212, 202, 243, 231); frames[DuckFrame::FALLING] = RectInt(245, 201, 263, 232); sounds[DuckSound::FLAP ].Load("./sfx/duckhunt/flap.wav" ); sounds[DuckSound::QUACK ].Load("./sfx/duckhunt/quack.wav" ); sounds[DuckSound::FALL ].Load("./sfx/duckhunt/fall.wav" ); sounds[DuckSound::HIT_GROUND].Load("./sfx/duckhunt/hitground.wav"); initSprite(sprite, sprites, frames[DuckFrame::NORM_1], DUCK_SCALE); setSpriteBuffer(sprite, buffer); sprite.SetPosition(Random::Random(buffer[LEFT], buffer[RIGHT]), START_HEIGHT); updateShotBox(); velocity = VectorFloat(0, 0); state = DuckState::IDLE; }
DotProductState::DotProductState() { //The Blue Falcon spritesheet is big enough to justify a new image file bfsprites.LoadFromFile("./gfx/bluefalcon.png"); bfsprites.SetSmooth(false); //Puts all the frames into this array. Order's weird due to the ordering of the sprites frames[19] = RectInt( 0, 0, 49, 43); frames[20] = RectInt( 55, 0, 106, 42); frames[21] = RectInt(114, 0, 167, 42); frames[22] = RectInt(175, 0, 229, 42); frames[23] = RectInt(237, 2, 293, 42); frames[24] = RectInt(301, 4, 363, 42); frames[25] = RectInt(371, 4, 435, 42); frames[26] = RectInt(443, 6, 507, 42); frames[27] = RectInt(515, 5, 579, 42); frames[28] = RectInt(587, 1, 649, 42); frames[29] = RectInt(656, 0, 711, 45); frames[30] = RectInt(713, 0, 758, 46); frames[31] = RectInt(766, 0, 806, 46); frames[ 0] = RectInt(814, 0, 852, 46); frames[ 1] = RectInt(860, 0, 900, 46); frames[ 2] = RectInt(903, 0, 948, 46); frames[ 3] = RectInt( 0, 43, 55, 88); frames[ 4] = RectInt( 61, 43, 122, 84); frames[ 5] = RectInt(130, 47, 194, 84); frames[ 6] = RectInt(202, 48, 266, 84); frames[ 7] = RectInt(274, 46, 338, 84); frames[ 8] = RectInt(346, 46, 408, 84); frames[ 9] = RectInt(416, 44, 472, 84); frames[10] = RectInt(480, 42, 534, 84); frames[11] = RectInt(542, 42, 595, 83); frames[12] = RectInt(604, 42, 656, 84); frames[13] = RectInt(665, 45, 713, 88); frames[14] = RectInt(715, 46, 767, 88); frames[15] = RectInt(775, 48, 831, 88); frames[16] = RectInt(839, 50, 897, 87); frames[17] = RectInt(900, 46, 955, 85); frames[18] = RectInt( 0, 88, 50, 129); //Prepares the actual sprite for on-screen display initSprite(bluefalcon, bfsprites, frames[0], BLUE_FALCON_SCALE); setSpriteBuffer(bluefalcon, buffer); //Adjust the collision boundaries based on the BF's frame }
bool ff::Value::Convert(Type type, Value **ppValue) const { assertRetVal(ppValue, false); *ppValue = nullptr; if (type == GetType()) { *ppValue = GetAddRef(const_cast<Value *>(this)); return true; } wchar_t buf[256]; switch (GetType()) { case Type::Null: switch (type) { case Type::String: CreateString(String(L"null"), ppValue); break; } break; case Type::Bool: switch (type) { case Type::Double: CreateDouble(AsBool() ? 1.0 : 0.0, ppValue); break; case Type::Float: CreateFloat(AsBool() ? 1.0f : 0.0f, ppValue); break; case Type::Int: CreateInt(AsBool() ? 1 : 0, ppValue); break; case Type::String: CreateString(AsBool() ? String(L"true") : String(L"false"), ppValue); break; } break; case Type::Double: switch (type) { case Type::Bool: CreateBool(AsDouble() != 0, ppValue); break; case Type::Float: CreateFloat((float)AsDouble(), ppValue); break; case Type::Int: CreateInt((int)AsDouble(), ppValue); break; case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%g", AsDouble()); CreateString(String(buf), ppValue); break; } break; case Type::Float: switch (type) { case Type::Bool: CreateBool(AsFloat() != 0, ppValue); break; case Type::Double: CreateDouble((double)AsFloat(), ppValue); break; case Type::Int: CreateInt((int)AsFloat(), ppValue); break; case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%g", AsFloat()); CreateString(String(buf), ppValue); break; } break; case Type::Int: switch (type) { case Type::Bool: CreateBool(AsInt() != 0, ppValue); break; case Type::Double: CreateDouble((double)AsInt(), ppValue); break; case Type::Float: CreateFloat((float)AsInt(), ppValue); break; case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%d", AsInt()); CreateString(String(buf), ppValue); break; } break; case Type::Point: switch (type) { case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%d,%d)", AsPoint().x, AsPoint().y); CreateString(String(buf), ppValue); break; } break; case Type::PointF: switch (type) { case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%g,%g)", AsPointF().x, AsPointF().y); CreateString(String(buf), ppValue); break; } break; case Type::Rect: switch (type) { case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%d,%d,%d,%d)", AsRect().left, AsRect().top, AsRect().right, AsRect().bottom); CreateString(String(buf), ppValue); break; } break; case Type::RectF: switch (type) { case Type::String: _snwprintf_s(buf, _countof(buf), _TRUNCATE, L"(%g,%g,%g,%g)", AsRectF().left, AsRectF().top, AsRectF().right, AsRectF().bottom); CreateString(String(buf), ppValue); break; } break; case Type::String: switch (type) { case Type::Bool: if (AsString().empty() || AsString() == L"false" || AsString() == L"no" || AsString() == L"0") { CreateBool(false, ppValue); } else if (AsString() == L"true" || AsString() == L"yes" || AsString() == L"1") { CreateBool(true, ppValue); } break; case Type::Double: { const wchar_t *start = AsString().c_str(); wchar_t *end = nullptr; double val = wcstod(start, &end); if (end > start && !*end) { CreateDouble(val, ppValue); } } break; case Type::Float: { const wchar_t *start = AsString().c_str(); wchar_t *end = nullptr; double val = wcstod(start, &end); if (end > start && !*end) { CreateFloat((float)val, ppValue); } } break; case Type::Int: { const wchar_t *start = AsString().c_str(); wchar_t *end = nullptr; long val = wcstol(start, &end, 10); if (end > start && !*end) { CreateInt((int)val, ppValue); } } break; case Type::Guid: { GUID guid; if (StringToGuid(AsString(), guid)) { CreateGuid(guid, ppValue); } } break; } break; case Type::Object: switch (type) { case Type::Bool: CreateBool(AsObject() != nullptr, ppValue); break; } break; case Type::Guid: switch (type) { case Type::String: CreateString(StringFromGuid(AsGuid()), ppValue); break; } break; case Type::Data: switch (type) { case Type::SavedData: { ff::ComPtr<ff::ISavedData> savedData; if (ff::CreateLoadedDataFromMemory(AsData(), false, &savedData)) { CreateSavedData(savedData, ppValue); } } break; } break; case Type::SavedData: switch (type) { case Type::Data: { ff::ComPtr<ff::ISavedData> savedData; if (AsSavedData()->Clone(&savedData)) { ff::ComPtr<ff::IData> data = savedData->Load(); if (data) { CreateData(data, ppValue); } } } break; } break; case Type::Dict: switch (type) { case Type::Data: case Type::SavedData: case Type::SavedDict: { ff::ComPtr<ff::IData> data; ff::ComPtr<ff::ISavedData> savedData; if (ff::SaveDict(AsDict(), true, false, &data)) { if (type == Type::Data) { CreateData(data, ppValue); } else if (ff::CreateLoadedDataFromMemory(data, true, &savedData)) { if (type == Type::SavedData) { CreateSavedData(savedData, ppValue); } else { CreateSavedDict(savedData, ppValue); } } } } break; } break; case Type::SavedDict: switch (type) { case Type::Data: { ff::ComPtr<ff::ISavedData> savedData; if (AsSavedData()->Clone(&savedData)) { ff::ComPtr<ff::IData> data = savedData->Load(); if (data) { CreateData(data, ppValue); } } } break; case Type::SavedData: CreateSavedData(AsSavedData(), ppValue); break; case Type::Dict: { ff::ComPtr<ff::ISavedData> savedData; if (AsSavedData()->Clone(&savedData)) { ff::ComPtr<ff::IData> data = savedData->Load(); ff::ComPtr<ff::IDataReader> dataReader; Dict dict; if (data && ff::CreateDataReader(data, 0, &dataReader) && ff::LoadDict(dataReader, dict)) { CreateDict(std::move(dict), ppValue); } } } break; } break; case Type::Resource: AsResource()->GetValue()->Convert(type, ppValue); break; case Type::IntVector: switch (type) { case Type::Point: if (AsIntVector().Size() == 2) { PointInt point( AsIntVector().GetAt(0), AsIntVector().GetAt(1)); CreatePoint(point, ppValue); } break; case Type::Rect: if (AsIntVector().Size() == 4) { RectInt rect( AsIntVector().GetAt(0), AsIntVector().GetAt(1), AsIntVector().GetAt(2), AsIntVector().GetAt(3)); CreateRect(rect, ppValue); } break; } break; case Type::FloatVector: switch (type) { case Type::PointF: if (AsFloatVector().Size() == 2) { PointFloat point( AsFloatVector().GetAt(0), AsFloatVector().GetAt(1)); CreatePointF(point, ppValue); } break; case Type::RectF: if (AsFloatVector().Size() == 4) { RectFloat rect( AsFloatVector().GetAt(0), AsFloatVector().GetAt(1), AsFloatVector().GetAt(2), AsFloatVector().GetAt(3)); CreateRectF(rect, ppValue); } break; } break; case Type::ValueVector: switch (type) { case Type::Point: if (AsValueVector().Size() == 2) { ValuePtr newValues[2]; const Vector<ValuePtr> &values = AsValueVector(); if (values[0]->Convert(Type::Int, &newValues[0]) && values[1]->Convert(Type::Int, &newValues[1])) { CreatePoint(PointInt(newValues[0]->AsInt(), newValues[1]->AsInt()), ppValue); } } break; case Type::PointF: if (AsValueVector().Size() == 2) { ValuePtr newValues[2]; const Vector<ValuePtr> &values = AsValueVector(); if (values[0]->Convert(Type::Float, &newValues[0]) && values[1]->Convert(Type::Float, &newValues[1])) { CreatePointF(PointFloat(newValues[0]->AsFloat(), newValues[1]->AsFloat()), ppValue); } } break; case Type::Rect: if (AsValueVector().Size() == 4) { ValuePtr newValues[4]; const Vector<ValuePtr> &values = AsValueVector(); if (values[0]->Convert(Type::Int, &newValues[0]) && values[1]->Convert(Type::Int, &newValues[1]) && values[2]->Convert(Type::Int, &newValues[2]) && values[3]->Convert(Type::Int, &newValues[3])) { CreateRect(RectInt( newValues[0]->AsInt(), newValues[1]->AsInt(), newValues[2]->AsInt(), newValues[3]->AsInt()), ppValue); } } break; case Type::RectF: if (AsValueVector().Size() == 4) { ValuePtr newValues[4]; const Vector<ValuePtr> &values = AsValueVector(); if (values[0]->Convert(Type::Float, &newValues[0]) && values[1]->Convert(Type::Float, &newValues[1]) && values[2]->Convert(Type::Float, &newValues[2]) && values[3]->Convert(Type::Float, &newValues[3])) { CreateRectF(RectFloat( newValues[0]->AsFloat(), newValues[1]->AsFloat(), newValues[2]->AsFloat(), newValues[3]->AsFloat()), ppValue); } } break; case Type::StringVector: { bool valid = true; Vector<String> newValues; const Vector<ValuePtr> &values = AsValueVector(); for (ValuePtr oldValue : values) { ValuePtr newValue; valid = oldValue->Convert(Type::String, &newValue); if (valid) { newValues.Push(newValue->AsString()); } else { break; } } if (valid) { CreateStringVector(std::move(newValues), ppValue); } } break; case Type::IntVector: { bool valid = true; Vector<int> newValues; const Vector<ValuePtr> &values = AsValueVector(); for (ValuePtr oldValue : values) { ValuePtr newValue; valid = oldValue->Convert(Type::Int, &newValue); if (valid) { newValues.Push(newValue->AsInt()); } else { break; } } if (valid) { CreateIntVector(std::move(newValues), ppValue); } } break; case Type::DoubleVector: { bool valid = true; Vector<double> newValues; const Vector<ValuePtr> &values = AsValueVector(); for (ValuePtr oldValue : values) { ValuePtr newValue; valid = oldValue->Convert(Type::Double, &newValue); if (valid) { newValues.Push(newValue->AsDouble()); } else { break; } } if (valid) { CreateDoubleVector(std::move(newValues), ppValue); } } break; case Type::FloatVector: { bool valid = true; Vector<float> newValues; const Vector<ValuePtr> &values = AsValueVector(); for (ValuePtr oldValue : values) { ValuePtr newValue; valid = oldValue->Convert(Type::Float, &newValue); if (valid) { newValues.Push(newValue->AsFloat()); } else { break; } } if (valid) { CreateFloatVector(std::move(newValues), ppValue); } } break; } break; } if (*ppValue) { return true; } return false; }