Example #1
0
void Server::HandleEvent(std::shared_ptr<dt::Event> e) {
    // This is quite useful for debugging purposes.
    //dt::Logger::Get().Info("There are " + boost::lexical_cast<QString>(dt::ConnectionsManager::Get()->GetConnectionCount()) + " connections active.");

    if(e->GetType() == "CHATMESSAGEEVENT") {
        std::shared_ptr<ChatMessageEvent> c = std::dynamic_pointer_cast<ChatMessageEvent>(e);

        if(c->IsLocalEvent()) { // we just received this

            if(c->GetMessageEvent() == "/help") {
                QString msg = "\nThe following commands are available:\n    /help - This message\n    /quit - disconnects from the server\n    /nick [nickname] - changes your nickname";
                dt::EventManager::Get()->
                    InjectEvent(std::make_shared<ChatMessageEvent>(msg, c->GetSenderNick()));
            } else {
                std::cout << std::endl << c->GetSenderNick().toStdString() << ": " << c->GetMessageEvent().toStdString() << std::endl;
            }

            // send back to everyone else
            dt::EventManager::Get()->
                InjectEvent(std::make_shared<ChatMessageEvent>(c->GetMessageEvent(), c->GetSenderNick()));
        }

    } else if(e->GetType() == "DT_GOODBYEEVENT") {
        dt::Logger::Get().Info("Client disconnected: " + std::dynamic_pointer_cast<dt::GoodbyeEvent>(e)->GetReason());
    }
}
Example #2
0
void GuiManager::HandleEvent(std::shared_ptr<Event> e) {
    if(mGuiSystem == nullptr)
        return;

    // inject the events into the gui system
    auto mygui_inputmgr = MyGUI::InputManager::getInstancePtr();
    if(mygui_inputmgr == nullptr) {
        return;
    }

    if(e->GetType() == "DT_MOUSEEVENT") {
        std::shared_ptr<MouseEvent> m = std::dynamic_pointer_cast<MouseEvent>(e);
        if(m->GetAction() ==  MouseEvent::MOVED) {
            mygui_inputmgr->injectMouseMove(m->GetMouseState().X.abs,
                                           m->GetMouseState().Y.abs,
                                           m->GetMouseState().Z.abs);
        } else if(m->GetAction() ==  MouseEvent::PRESSED) {
            mygui_inputmgr->injectMousePress(m->GetMouseState().X.abs,
                                             m->GetMouseState().Y.abs,
                                        MyGUI::MouseButton::Enum(m->GetButton()));
        } else if(m->GetAction() ==  MouseEvent::RELEASED) {
            mygui_inputmgr->injectMouseRelease(m->GetMouseState().X.abs,
                                               m->GetMouseState().Y.abs,
                                        MyGUI::MouseButton::Enum(m->GetButton()));
        }
    } else if(e->GetType() == "DT_KEYBOARDEVENT") {
        std::shared_ptr<KeyboardEvent> k = std::dynamic_pointer_cast<KeyboardEvent>(e);
        if(k->GetAction() == KeyboardEvent::PRESSED) {
            mygui_inputmgr->injectKeyPress(MyGUI::KeyCode::Enum(k->GetCode()),
                                           k->GetText());
        } else if(k->GetAction() == KeyboardEvent::RELEASED) {
            mygui_inputmgr->injectKeyRelease(MyGUI::KeyCode::Enum(k->GetCode()));
        }
    }
}
Example #3
0
	void Pacman::OnCollision(const std::shared_ptr<ICollider>& collidedWith)
	{	
		if (collidedWith->GetType() == Type::Ghost) // or we hit a normal ghost
			m_State = PacState::Dead;

		else if (collidedWith->GetType() == Type::Power && m_State != PacState::PowerUp)// or we hit a powerup
		{
			m_State = PacState::PowerUp;
			m_powerDuration = Timer::GetTime();//start duration
		}
	}
Example #4
0
std::shared_ptr<Expression> ArrayType::PrimitiveAccessMember(std::shared_ptr<Expression> self, unsigned num) {
    assert(num < count);
    auto result_ty = IsLvalueType(self->GetType())
        ? t->analyzer.GetLvalueType(t)
        : IsRvalueType(self->GetType())
        ? t->analyzer.GetRvalueType(t)
        : t;
    return CreatePrimGlobal(Range::Elements(self), result_ty, [=](CodegenContext& con) {
        auto val = self->GetValue(con);
        return con.CreateStructGEP(val, num);
    });
}
std::shared_ptr<OGLDrawObject> OpenGLEngine::Bind (std::shared_ptr<DrawObject> const& dObject)
{
	if (!dObject)
	{
		fprintf (stderr, "The bind method in OpenGLEngine failed, because the input argument is not correct.\n");
		return nullptr;
	}
	
	std::shared_ptr<OGLDrawObject> oglObject;
	if (!m_MapDO.Get (dObject, oglObject))
	{
		CreateOGLObject create = m_CreateOGLObject[dObject->GetType ()];
		if (!create)
		{
			fprintf (stderr, "The bind method in OpenGLEngine failed, because a create function was not found.\n");
			return nullptr;
		}

		oglObject = create (dObject);

		if (!oglObject)
		{
			fprintf (stderr, "The bind method in OpenGLEngine failed, because the created OGL Object was not correct.\n");
		}

		m_MapDO.Insert (dObject, oglObject);
	}

	return oglObject;
}
Example #6
0
    void HandleEvent(std::shared_ptr<dt::Event> e) {
        if(e->GetType() == "DT_BEGINFRAMEEVENT") {
            mRuntime += std::dynamic_pointer_cast<dt::BeginFrameEvent>(e)->GetFrameTime();

            if(mRuntime >= 0 && mStep == 0) {
                mStep = 1;
                dt::Logger::Get().Debug("Mode: Hidden");
                dt::InputManager::Get()->SetMouseCursorMode(dt::InputManager::HIDDEN);
            } else if(mRuntime >= 0.5 && mStep == 1) {
                mStep = 2;
                dt::Logger::Get().Debug("Mode: Graphical");
                dt::InputManager::Get()->SetMouseCursorMode(dt::InputManager::GRAPHICAL);
            } else if(mRuntime >= 1.0 && mStep == 2) {
                mStep = 3;
                dt::Logger::Get().Debug("Mode: System");
                dt::InputManager::Get()->SetMouseCursorMode(dt::InputManager::SYSTEM);
            } else if(mRuntime >= 1.5 && mStep == 3) {
                mStep = 4;
                dt::Logger::Get().Debug("Mode: Graphical again");
                dt::InputManager::Get()->SetMouseCursorMode(dt::InputManager::GRAPHICAL);
            } else if(mRuntime >= 2.0 && mStep == 4) {
               mStep = 5;
               dt::Logger::Get().Debug("Mode: Hidden again");
               dt::InputManager::Get()->SetMouseCursorMode(dt::InputManager::HIDDEN);
            }
            if(mRuntime > 2.5) {
                dt::StateManager::Get()->Pop(1);
            }
        }
    }
Example #7
0
void Box2DPhysics::AddBox(std::shared_ptr<Actor> actor, float density, std::string type, bool fixedRotation, bool isSensor, float hitboxScale)
{
    b2BodyDef bodyDef;
    bodyDef.position.Set(PixelsToMeters(actor->GetPosition().x + actor->GetScale().x * 0.5), PixelsToMeters(actor->GetPosition().y + actor->GetScale().y * 0.5)); // position should be center of object instead of top-left
    if (type == "dynamic")
        bodyDef.type = b2_dynamicBody;
    else if (type == "kinematic")
        bodyDef.type = b2_kinematicBody;
    bodyDef.fixedRotation = fixedRotation;
    b2Body* body = m_World->CreateBody(&bodyDef);

    BodyUserData *userData = new BodyUserData;
    userData->Physics = this;
    userData->Type = actor->GetType();
    body->SetUserData((void*)userData);

    b2PolygonShape shape;
    shape.SetAsBox(PixelsToMeters(hitboxScale * actor->GetScale().x * 0.5), PixelsToMeters(hitboxScale * actor->GetScale().y * 0.5));

    b2FixtureDef fixture;
    fixture.shape = &shape;
    fixture.density = density;
    fixture.isSensor = isSensor;

    body->CreateFixture(&fixture);

    m_BodyToActorID[body] = actor->GetID();
    m_ActorIDToBody[actor->GetID()] = body;
}
Example #8
0
void Box2DPhysics::AddPolygon(std::shared_ptr<Actor> actor, std::vector<glm::vec2> vertices, float density, bool dynamic, bool fixedRotation)
{
    b2BodyDef bodyDef;
    bodyDef.position.Set(PixelsToMeters(actor->GetPosition().x + actor->GetScale().x * 0.5), PixelsToMeters(actor->GetPosition().y + actor->GetScale().y * 0.5)); // position should be center of object instead of top-left
    if(dynamic)
        bodyDef.type = b2_dynamicBody;
    bodyDef.fixedRotation = fixedRotation;
    b2Body* body = m_World->CreateBody(&bodyDef);
    
    BodyUserData *userData = new BodyUserData;
    userData->Physics = this;
    userData->Type = actor->GetType();
    body->SetUserData((void*)userData);

    // create 8 vertices 
    b2Vec2 verts[8];
    for(unsigned int i = 0; i < vertices.size(); ++i)
        verts[i].Set(PixelsToMeters(vertices[i].x * actor->GetScale().x * 0.5), PixelsToMeters(vertices[i].y * actor->GetScale().y * 0.5));
    b2PolygonShape shape;    
    shape.Set(verts, 8);
   
    b2FixtureDef fixture;
    fixture.shape = &shape;
    fixture.density = density;
    
    body->CreateFixture(&fixture);

    m_BodyToActorID[body] = actor->GetID();
    m_ActorIDToBody[actor->GetID()] = body;
}
void SimpleSdlRenderer::Render(const std::shared_ptr<Extra>& extra)
{
   const auto pos = extra->GetPosition();
   const auto size = extra->GetSize();

   SDL_Rect rect = { static_cast<Sint16>(pos.X),
                     static_cast<Sint16>(pos.Y),
                     static_cast<Uint16>(size.Width),
                     static_cast<Uint16>(size.Height) };

   int color = 0;

   switch (extra->GetType())
   {
      case ExtraType::Speed:
         color = 0xff0000;
         break;
      case ExtraType::Range:
         color = 0x00ff00;
         break;
      case ExtraType::Bombs:
         color = 0x0000ff;
         break;
      case ExtraType::InfiniteRange:
         color = 0xff1fff;
         break;
      default:
         break;
   }

   SDL_FillRect(mScreen, &rect, color);
}
 void HandleEvent(std::shared_ptr<dt::Event> e) {
     if(e->GetType() == "DT_BEGINFRAMEEVENT") {
         mRuntime += std::dynamic_pointer_cast<dt::BeginFrameEvent>(e)->GetFrameTime();
         if(mRuntime > 2.5) {
             dt::StateManager::Get()->Pop(1);
         }
     }
 }
Example #11
0
void Client::_HandleEvent(std::shared_ptr<dt::NetworkEvent> e) {
    if(e->GetType() == "CHATMESSAGEEVENT") {
        std::shared_ptr<ChatMessageEvent> c = std::dynamic_pointer_cast<ChatMessageEvent>(e);
        //if(c->IsLocalEvent()) { // we just received this
        std::cout << std::endl << "<" << dt::Utils::ToStdString(c->GetSenderNick()) << "> " << dt::Utils::ToStdString(c->GetMessageText()) << std::endl;
        //}
    }
}
Example #12
0
void CustomClientEventListener::_HandleEvent(std::shared_ptr<dt::NetworkEvent> e) {
    if(e->GetType() == "CUSTOMNETWORKEVENT") {
        std::shared_ptr<CustomNetworkEvent> c = std::dynamic_pointer_cast<CustomNetworkEvent>(e);
        if(c->mEnum == CustomNetworkEvent::SERVER) {
            std::cout << "Client: received CustomNetworkEvent" << std::endl;
            mDataReceived = c->mData;
        }
    }
}
std::shared_ptr<OGLDrawObject> OGLBlendState::Create (std::shared_ptr<const DrawObject> dObject)
{
	if (dObject->GetType ()== DP_BLEND_STATE)
	{
		return std::make_shared<OGLBlendState> (std::static_pointer_cast<const BlendState> (dObject));
	}

	fprintf (stderr, "The create method of OGLBlendState failed, because the type of the object is incorrect./n");
	return nullptr;
}
Example #14
0
bool game::Entity::AddComponent(std::shared_ptr<game::Component> comp)
{
	// there should only be one type of component per entity
	auto c = GetComponent(comp->GetType());
	if (c == nullptr)
	{
		_components.push_back(comp);
		return true;
	}
	return false;
}
Example #15
0
void CustomServerEventListener::_HandleEvent(std::shared_ptr<dt::NetworkEvent> e) {
    if(e->GetType() == "CUSTOMNETWORKEVENT") {
        std::shared_ptr<CustomNetworkEvent> c = std::dynamic_pointer_cast<CustomNetworkEvent>(e);
        if(c->mEnum == CustomNetworkEvent::CLIENT) {
            std::cout << "Server: received CustomNetworkEvent" << std::endl;
            // send it back, adding 1 to the data
           dt::NetworkManager::Get()->
                QueueEvent(std::make_shared<CustomNetworkEvent>(c->mData + DATA_INCREMENT, CustomNetworkEvent::SERVER));
            mDataReceived = c->mData;
        }
    }
}
    bool
    Handle( std::shared_ptr<BlurryRoots::Yanecos::IEvent> someEvent )
    {
        if( someEvent->GetType() == typeid( ActorMoveRequestEvent ) )
        {
            auto event =
                std::static_pointer_cast<ActorMoveRequestEvent>(
                    someEvent
                );

            _moveRequests.push_back( event );
        }
    }
Example #17
0
void Box2DPhysics::AddCharacter(std::shared_ptr<Actor> actor, float density)
{
    b2BodyDef bodyDef;
    bodyDef.position.Set(PixelsToMeters(actor->GetPosition().x + actor->GetScale().x * 0.5), PixelsToMeters(actor->GetPosition().y + actor->GetScale().y * 0.5)); // position should be center of object instead of top-left
    bodyDef.type = b2_dynamicBody;
    bodyDef.fixedRotation = true;
    bodyDef.allowSleep = false;
    b2Body* body = m_World->CreateBody(&bodyDef);
    body->SetBullet(true);

    BodyUserData *userData = new BodyUserData;
    userData->Physics = this;
    userData->Type = actor->GetType();
    body->SetUserData((void*)userData);

    // Create box top-shape
    b2PolygonShape boxShape;
    b2Vec2 vertices[4];
    vertices[0].Set(PixelsToMeters(-actor->GetScale().x * 0.2), PixelsToMeters(-actor->GetScale().y * 0.5));
    vertices[1].Set(PixelsToMeters(-actor->GetScale().x * 0.2), PixelsToMeters(actor->GetScale().y * 0.2));
    vertices[2].Set(PixelsToMeters(actor->GetScale().x * 0.2), PixelsToMeters(actor->GetScale().y * 0.2));
    vertices[3].Set(PixelsToMeters(actor->GetScale().x * 0.2), PixelsToMeters(-actor->GetScale().y * 0.5));
    boxShape.Set(vertices, 4);
    b2FixtureDef fixture;
    fixture.shape = &boxShape;
    fixture.density = density;
    fixture.friction = 0.95f;
    body->CreateFixture(&fixture);
    // Create circle bottom-shape
    b2CircleShape circleShape;
    circleShape.m_p.Set(0.0f, PixelsToMeters(actor->GetScale().y * 0.46 - actor->GetScale().x * 0.20));
    circleShape.m_radius = PixelsToMeters(actor->GetScale().x * 0.23);
    b2FixtureDef fixture2;
    fixture2.shape = &circleShape;
    fixture2.density = density;
    fixture2.friction = 1.9f;
    body->CreateFixture(&fixture2);

    // Create bottom sensor to detect floor-collisions
    b2PolygonShape sensorShape;
    b2Vec2 origin = b2Vec2(0.0, PixelsToMeters(actor->GetScale().y * 0.44));
    sensorShape.SetAsBox(PixelsToMeters(actor->GetScale().x * 0.05), PixelsToMeters(actor->GetScale().y * 0.05), origin, 0.0f);
    b2FixtureDef fixture3;
    fixture3.shape = &sensorShape;
    fixture3.isSensor = true;
    body->CreateFixture(&fixture3);


    m_BodyToActorID[body] = actor->GetID();
    m_ActorIDToBody[actor->GetID()] = body;
}
Example #18
0
	bool Matcher::Equals(const std::shared_ptr<void> &obj) {
		if(obj == nullptr || obj->GetType() != GetType() || obj->GetHashCode() != GetHashCode())
			return false;

		auto matcher = std::static_pointer_cast<Matcher>(obj);
		if(!equalIndices(matcher->GetallOfIndices(), _allOfIndices))
			return false;
		if(!equalIndices(matcher->GetanyOfIndices(), _anyOfIndices))
			return false;
		if(!equalIndices(matcher->GetnoneOfIndices(), _noneOfIndices))
			return false;

		return true;
	}
Example #19
0
    void HandleEvent(std::shared_ptr<dt::Event> e) {
        if(e->GetType() == "DT_BEGINFRAMEEVENT") {
            double time_diff = std::dynamic_pointer_cast<dt::BeginFrameEvent>(e)->GetFrameTime();
            mRuntime += time_diff;

            dt::Scene* scene = GetScene("testscene");
            dt::Node* node2 = scene->FindChildNode("node2");
            node2->SetPosition(node2->GetPosition() + (Ogre::Vector3(-8, -8, 0) * time_diff));

            if(mRuntime > 2.5) {
                dt::StateManager::Get()->Pop(1);
            }
        }
    }
void SimplePlayerComponent::HandleEvent(std::shared_ptr<Event> e) {
    // do not react to any events if this component is disabled
    if(!IsEnabled())
        return;

    if(mMouseEnabled && e->GetType() == "DT_MOUSEEVENT") {
        std::shared_ptr<MouseEvent> m = std::dynamic_pointer_cast<MouseEvent>(e);
        if(m->GetAction() == MouseEvent::MOVED) {
            float factor = mMouseSensitivity * -0.01;
            float dx = m->GetMouseState().X.rel * factor;
            float dy = m->GetMouseState().Y.rel * factor * (mMouseYInversed ? -1 : 1);

            if(dx != 0 || dy != 0) {
                // watch out for da gimbal lock !!

                Ogre::Matrix3 orientMatrix;
                GetNode()->GetRotation().ToRotationMatrix(orientMatrix);

                Ogre::Radian yaw, pitch, roll;
                orientMatrix.ToEulerAnglesYXZ(yaw, pitch, roll);

                pitch += Ogre::Radian(dy);
                yaw += Ogre::Radian(dx);

                // do not let it look completely vertical, or the yaw will break
                if(pitch > Ogre::Degree(89.9))
                    pitch = Ogre::Degree(89.9);

                if(pitch < Ogre::Degree(-89.9))
                    pitch = Ogre::Degree(-89.9);

                orientMatrix.FromEulerAnglesYXZ(yaw, pitch, roll);

                Ogre::Quaternion rot;
                rot.FromRotationMatrix(orientMatrix);
                GetNode()->SetRotation(rot);
            }
        }
    }
}
void SimpleSdlRenderer::Render(const std::shared_ptr<Wall>& wall)
{
   const auto pos = wall->GetPosition();
   const auto size = wall->GetSize();

   SDL_Rect rect = { static_cast<Sint16>(pos.X),
                     static_cast<Sint16>(pos.Y),
                     static_cast<Uint16>(size.Width),
                     static_cast<Uint16>(size.Height) };

   int color = 0;

   if (WallType::Destructible == wall->GetType())
   {
      color = 0x7f7f7f;
   }
   else
   {
      color = 0x4f4f4f;
   }

   SDL_FillRect(mScreen, &rect, color);
}
Example #22
0
 void HandleEvent(std::shared_ptr<dt::Event> e) {
     if(e->GetType() == "cancelevent") {
         dt::Logger::Get().Info("CancelListener: Canceling event");
         e->Cancel();
     }
 }
Example #23
0
	void Layer::Add( std::shared_ptr< Object > NewObject ) {
		if( NewObject->GetType() == GetType() || GetSize() == 0 ) {
			m_objects.push_back( NewObject );
		}
	}
void TriggerComponent::HandleEvent(std::shared_ptr<Event> e) {
    if(e->GetType() == "trigger") {

    }
}
Example #25
0
bool CSettingsOperations::SerializeSetting(std::shared_ptr<const CSetting> setting, CVariant &obj)
{
  if (!SerializeISetting(setting, obj))
    return false;

  obj["label"] = g_localizeStrings.Get(setting->GetLabel());
  if (setting->GetHelp() >= 0)
    obj["help"] = g_localizeStrings.Get(setting->GetHelp());

  switch (setting->GetLevel())
  {
    case SettingLevelBasic:
      obj["level"] = "basic";
      break;

    case SettingLevelStandard:
      obj["level"] = "standard";
      break;

    case SettingLevelAdvanced:
      obj["level"] = "advanced";
      break;

    case SettingLevelExpert:
      obj["level"] = "expert";
      break;

    default:
      return false;
  }

  obj["enabled"] = setting->IsEnabled();
  obj["parent"] = setting->GetParent();

  obj["control"] = CVariant(CVariant::VariantTypeObject);
  if (!SerializeSettingControl(setting->GetControl(), obj["control"]))
    return false;

  switch (setting->GetType())
  {
    case SettingTypeBool:
      obj["type"] = "boolean";
      if (!SerializeSettingBool(std::static_pointer_cast<const CSettingBool>(setting), obj))
        return false;
      break;

    case SettingTypeInteger:
      obj["type"] = "integer";
      if (!SerializeSettingInt(std::static_pointer_cast<const CSettingInt>(setting), obj))
        return false;
      break;

    case SettingTypeNumber:
      obj["type"] = "number";
      if (!SerializeSettingNumber(std::static_pointer_cast<const CSettingNumber>(setting), obj))
        return false;
      break;

    case SettingTypeString:
      obj["type"] = "string";
      if (!SerializeSettingString(std::static_pointer_cast<const CSettingString>(setting), obj))
        return false;
      break;

    case SettingTypeAction:
      obj["type"] = "action";
      if (!SerializeSettingAction(std::static_pointer_cast<const CSettingAction>(setting), obj))
        return false;
      break;

    case SettingTypeList:
      obj["type"] = "list";
      if (!SerializeSettingList(std::static_pointer_cast<const CSettingList>(setting), obj))
        return false;
      break;

    default:
      return false;
  }

  return true;
}
Example #26
0
bool CSettingsOperations::SerializeSettingControl(std::shared_ptr<const ISettingControl> control, CVariant &obj)
{
  if (control == NULL)
    return false;
  
  const std::string& type = control->GetType();
  obj["type"] = type;
  obj["format"] = control->GetFormat();
  obj["delayed"] = control->GetDelayed();

  if (type == "spinner")
  {
    std::shared_ptr<const CSettingControlSpinner> spinner = std::static_pointer_cast<const CSettingControlSpinner>(control);
    if (spinner->GetFormatLabel() >= 0)
      obj["formatlabel"] = g_localizeStrings.Get(spinner->GetFormatLabel());
    else if (!spinner->GetFormatString().empty() && spinner->GetFormatString() != "%i")
      obj["formatlabel"] = spinner->GetFormatString();
    if (spinner->GetMinimumLabel() >= 0)
      obj["minimumlabel"] = g_localizeStrings.Get(spinner->GetMinimumLabel());
  }
  else if (type == "edit")
  {
    std::shared_ptr<const CSettingControlEdit> edit = std::static_pointer_cast<const CSettingControlEdit>(control);
    obj["hidden"] = edit->IsHidden();
    obj["verifynewvalue"] = edit->VerifyNewValue();
    if (edit->GetHeading() >= 0)
      obj["heading"] = g_localizeStrings.Get(edit->GetHeading());
  }
  else if (type == "button")
  {
    std::shared_ptr<const CSettingControlButton> button = std::static_pointer_cast<const CSettingControlButton>(control);
    if (button->GetHeading() >= 0)
      obj["heading"] = g_localizeStrings.Get(button->GetHeading());
  }
  else if (type == "list")
  {
    std::shared_ptr<const CSettingControlList> list = std::static_pointer_cast<const CSettingControlList>(control);
    if (list->GetHeading() >= 0)
      obj["heading"] = g_localizeStrings.Get(list->GetHeading());
    obj["multiselect"] = list->CanMultiSelect();
  }
  else if (type == "slider")
  {
    std::shared_ptr<const CSettingControlSlider> slider = std::static_pointer_cast<const CSettingControlSlider>(control);
    if (slider->GetHeading() >= 0)
      obj["heading"] = g_localizeStrings.Get(slider->GetHeading());
    obj["popup"] = slider->UsePopup();
    if (slider->GetFormatLabel() >= 0)
      obj["formatlabel"] = g_localizeStrings.Get(slider->GetFormatLabel());
    else
      obj["formatlabel"] = slider->GetFormatString();
  }
  else if (type == "range")
  {
    std::shared_ptr<const CSettingControlRange> range = std::static_pointer_cast<const CSettingControlRange>(control);
    if (range->GetFormatLabel() >= 0)
      obj["formatlabel"] = g_localizeStrings.Get(range->GetFormatLabel());
    else
      obj["formatlabel"] = "";
    if (range->GetValueFormatLabel() >= 0)
      obj["formatvalue"] = g_localizeStrings.Get(range->GetValueFormatLabel());
    else
      obj["formatvalue"] = range->GetValueFormat();
  }
  else if (type != "toggle")
    return false;

  return true;
}
Example #27
0
void Scene::HandleEvent(std::shared_ptr<Event> e) {
    if(e->GetType() == "DT_BEGINFRAMEEVENT") {
        OnUpdate((std::dynamic_pointer_cast<BeginFrameEvent>(e))->GetFrameTime());
    }
}
Example #28
0
#define CATCH_CONFIG_MAIN
#include "PolyHook.h"
#include "CatchUnitTest.h"

decltype(&MessageBoxA) oMessageBoxA;
int WINAPI hkMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
	int Result = oMessageBoxA(hWnd, "Hooked", lpCaption, uType);
	REQUIRE(strcmp("Message",lpText) == 0);
	return -10;
}

TEST_CASE("Hooks MessageBox", "[Detours]")
{
	std::shared_ptr<PLH::Detour> Detour_Ex(new PLH::Detour);
	REQUIRE(Detour_Ex->GetType() == PLH::HookType::Detour);

	Detour_Ex->SetupHook((BYTE*)&MessageBoxA,(BYTE*) &hkMessageBoxA); //can cast to byte* to
	REQUIRE( Detour_Ex->Hook() );
	oMessageBoxA = Detour_Ex->GetOriginal<decltype(&MessageBoxA)>();

	REQUIRE(MessageBoxA(NULL, "Message", "Sample", MB_OK) == -10); //The return value set by our handler
	Detour_Ex->UnHook();
	REQUIRE(MessageBoxA(NULL, "Message", "Sample", MB_OK) == IDOK);

	REQUIRE(Detour_Ex->GetLastError().GetSeverity() != PLH::RuntimeError::Severity::UnRecoverable);
	REQUIRE(Detour_Ex->GetLastError().GetSeverity() != PLH::RuntimeError::Severity::Critical);
}

decltype(&WriteProcessMemory) oWriteProcessMemory;
BYTE DummyBuffer2[] = { 0x13,0x24,0x36,0x38 };
Example #29
0
 void HandleEvent(std::shared_ptr<dt::Event> e) {
     if(e->GetType() == "cancelevent") {
         std::cerr << "Error: NonCancelListener should not receive a CancelEvent." << std::endl;
         exit(1);
     }
 }
Example #30
0
 void HandleEvent(std::shared_ptr<dt::Event> e) {
     if(e->GetType() == "testevent") {
         mHasReceivedTestEvent = true;
     }
     mHasReceivedAnEvent = true;
 }