/// Get the button
void GameEconomicGameClient::HandlerConfigurationWindowButtonPressed(StringHash eventType, VariantMap& eventData)
{
    /// Get needed resources
    Renderer* renderer = GetSubsystem<Renderer>();
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    UI* ui_ = GetSubsystem<UI>();

    UIElement * UIRoot = ui_->GetRoot();

    GameStateHandlerComponent * gamestatehandlercomponent_ = GetSubsystem<GameStateHandlerComponent>();

    /// get the button that was clicked
    Button* clicked = static_cast<Button*>(eventData[UIMouseClick::P_ELEMENT].GetPtr());

    /// Get TheName
    String ClickedButton(clicked->GetName().ToLower());

    /// If exit was clicked
    if (ClickedButton.Contains("apply")==true)
    {
        /// Get parameters
        Slider * VideoBloomParam1= (Slider *)UIRoot->GetChild("VideoBloomParam1Slider",true);
        Slider * VideoBloomParam2= (Slider *)UIRoot->GetChild("VideoBloomParam2Slider",true);

        float VideoBloomParam1Value = VideoBloomParam1->GetValue();
        float VideoBloomParam2Value = VideoBloomParam2->GetValue();

        /// Set parameter
        effectRenderPath->SetShaderParameter("BloomMix", Vector2(VideoBloomParam1Value,VideoBloomParam2Value));

        return;
    }

    /// If exit was clicked
    if (ClickedButton.Contains("save")==true)
    {
        /// Get parameters
        Slider * VideoBloomParam1= (Slider *)UIRoot->GetChild("VideoBloomParam1Slider",true);
        Slider * VideoBloomParam2= (Slider *)UIRoot->GetChild("VideoBloomParam2Slider",true);
        CheckBox * GameForceTabletModeCheckBox = (CheckBox *) UIRoot->GetChild("GameForceTabletModeCheckBox",true);

        ///Create new config
        Configuration SaveNewConfig;

        /// Copy info
        SaveNewConfig.GameModeForceTablet=  GameForceTabletModeCheckBox->IsChecked();
        SaveNewConfig.VideoBloomParam1 = VideoBloomParam1->GetValue();
        SaveNewConfig.VideoBloomParam2 = VideoBloomParam2->GetValue();

        /// Save new config
        SaveConfiguration(SaveNewConfig);

        return;
    }

    return;
}
Exemplo n.º 2
0
void UIDrag::HandleUpdate(StringHash eventType, VariantMap& eventData)
{
    auto* ui = GetSubsystem<UI>();
    UIElement* root = ui->GetRoot();

    auto* input = GetSubsystem<Input>();

    unsigned n = input->GetNumTouches();
    for (unsigned i = 0; i < n; i++)
    {
        Text* t = (Text*)root->GetChild("Touch " + String(i));
        TouchState* ts = input->GetTouch(i);
        t->SetText("Touch " + String(ts->touchID_));

        IntVector2 pos = ts->position_;
        pos.y_ -= 30;

        t->SetPosition(pos);
        t->SetVisible(true);
    }

    for (unsigned i = n; i < 10; i++)
    {
        Text* t = (Text*)root->GetChild("Touch " + String(i));
        t->SetVisible(false);
    }

    if (input->GetKeyPress(KEY_SPACE))
    {
        PODVector<UIElement*> elements;
        root->GetChildrenWithTag(elements, "SomeTag");
        for (PODVector<UIElement*>::ConstIterator i = elements.Begin(); i != elements.End(); ++i)
        {
            UIElement* element = *i;
            element->SetVisible(!element->IsVisible());
        }
    }
}
void GameEconomicGameClient::UpdateNetworkStatusUI(bool online)
{
    /// Get Urho3D Subsystem
    UI* ui_ = GetSubsystem<UI>();

    /// load window
    UIElement * uiroot = ui_->	GetRoot ();

    Text * NetworkStatusUpdateText = (Text *) uiroot->GetChild("ServerStatusUpdateText",true);

    if(NetworkStatusUpdateText)
    {
        if(online)
        {
            NetworkStatusUpdateText->SetText("Online");
        }
        else
        {
            NetworkStatusUpdateText->SetText("Offline");
        }
    }

    return;
}
Exemplo n.º 4
0
void Board::Update(float timeStep)
{
    if (gameOver_)
    {
        if (score_ > record_)
        {
            record_ = score_;
            SaveRecord();
        }
        Restart();
        return;
    }

    selectionNode_->Rotate(Quaternion(0.0f, timeStep * 50, 0.0f));
    if (Path::GetTotalCount() > 0)
        return;
    if (needCheckLines_)
    {
        if (CheckLines())
        {
            needSpawnBalls_ = false;
        }
        needCheckLines_ = false;
        // может быть что поле полностью занято, новых шаров спанить не надо и ходить некуда
        // не работает чот
        gameOver_ = true;
        for (int i = 0; i < height_; i++)
        {
            for (int j = 0; j < width_; j++)
            {
                if (!board_[i][j] || board_[i][j]->GetBallState() == BS_GHOST)
                {
                    gameOver_ = false;
                    break;
                }

            }
        }
        if (gameOver_)
            return;

    }
    if (needSpawnBalls_)
    {
        for (int i = 0; i < numAddBalls_; i++)
        {
            if (!SpawnBall())
            {
                gameOver_ = true;
                return;
            }
        }
        if (difficulty_ <= D_NORMAL)
        {
            for (int i = 0; i < numAddBalls_; i++)
                CreateBall(true);
        }
        needSpawnBalls_ = false;
    }

    UIElement* uiRoot = GetSubsystem<UI>()->GetRoot();
    Text* t = static_cast<Text*>(uiRoot->GetChild("Score", true));
    t->SetText("Score: " + String(score_));
    t = static_cast<Text*>(uiRoot->GetChild("Colors", true));
    t->SetText("Colors: " + String(numColors_));
    t = static_cast<Text*>(uiRoot->GetChild("LineLength", true));
    t->SetText("Line length: " + String(lineLength_));
    t = static_cast<Text*>(uiRoot->GetChild("Record", true));
    t->SetText("Record: " + String(record_));
    // нужно выбрасывать шары если после уделаения линий поле пустое
}