Example #1
0
bool RuntimeLightObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
    if ( propertyNb == 0 )
    {
        gd::String r, gb, g, b;
        {
            size_t separationPos = newValue.find(";");

            if ( separationPos > newValue.length())
                return false;

            r = newValue.substr(0, separationPos);
            gb = newValue.substr(separationPos+1, newValue.length());
        }

        {
            size_t separationPos = gb.find(";");

            if ( separationPos > gb.length())
                return false;

            g = gb.substr(0, separationPos);
            b = gb.substr(separationPos+1, gb.length());
        }

        SetColor(sf::Color(r.To<int>(), g.To<int>(), b.To<int>()));
    }
    else if ( propertyNb == 1 ) { SetIntensity(newValue.To<float>()); }
    else if ( propertyNb == 2 ) { SetRadius(newValue.To<float>()); }
    else if ( propertyNb == 3 ) { SetQuality(newValue.To<int>()); }

    return true;
}
Example #2
0
bool RuntimeTextObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
    if      ( propertyNb == 0 ) { SetString(newValue); return true; }
    else if ( propertyNb == 1 ) { ChangeFont(newValue); }
    else if ( propertyNb == 2 ) { SetCharacterSize(newValue.To<int>()); }
    else if ( propertyNb == 3 )
    {
        gd::String r, gb, g, b;
        {
            size_t separationPos = newValue.find(";");

            if ( separationPos > newValue.length())
                return false;

            r = newValue.substr(0, separationPos);
            gb = newValue.substr(separationPos+1, newValue.length());
        }

        {
            size_t separationPos = gb.find(";");

            if ( separationPos > gb.length())
                return false;

            g = gb.substr(0, separationPos);
            b = gb.substr(separationPos+1, gb.length());
        }

        SetColor(r.To<int>(), g.To<int>(), b.To<int>());
    }
    else if ( propertyNb == 4 ) { SetOpacity(newValue.To<float>()); }
    else if ( propertyNb == 5 ) { SetSmooth(!(newValue == _("No"))); }

    return true;
}
Example #3
0
bool RuntimeObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
    if ( propertyNb == 0 )
    {
        size_t separationPos = newValue.find(";");

        if ( separationPos > newValue.length())
            return false;

        gd::String xValue = newValue.substr(0, separationPos);
        gd::String yValue = newValue.substr(separationPos+1, newValue.length());

        SetX(xValue.To<float>());
        SetY(yValue.To<float>());
    }
    else if ( propertyNb == 1 ) {return SetAngle(newValue.To<float>());}
    else if ( propertyNb == 2 ) {return false;}
    else if ( propertyNb == 3 )
    {
        if ( newValue == _("Hidden") )
        {
            SetHidden();
        }
        else
            SetHidden(false);
    }
    else if ( propertyNb == 4 ) { layer = newValue; }
    else if ( propertyNb == 5 ) {SetZOrder(newValue.To<int>());}
    else if ( propertyNb == 6 ) {return false;}
    else if ( propertyNb == 7 ) {return false;}
    else if ( propertyNb == 8 ) {return false;}
    else if ( propertyNb == 9 ) {return false;}

    return true;
}
Example #4
0
/**
 * Expression function for getting a character from a string
 */
gd::String GD_API StrAt(const gd::String & str, size_t pos )
{
    if ( pos < str.size() )
        return str.substr(pos, 1);

    return "";
}
Example #5
0
/**
 * Expression function for getting a substring from a string
 */
gd::String GD_API SubStr(const gd::String & str, size_t start, size_t length )
{
    if ( start < str.size() )
        return str.substr(start, length);

    return "";
}
gd::String PathBehaviorEditor::GetNameWithoutPrefix(gd::String name)
{
    gd::String result;

    if(name.substr(0, 8) != "global: ")
    {
        return result = name;
    }
    else
    {
        gd::String::iterator namePlusEightIt = name.begin();
        std::advance(namePlusEightIt, 8);
        std::copy(namePlusEightIt, name.end(), std::back_inserter(result));

        return result;
    }
}
Example #7
0
    void GetPropertyForDebugger(RuntimeScene & scene, std::size_t propertyNb, gd::String & name, gd::String & value) const
    {
        std::size_t i = 0;
        std::map < gd::String, ManualTimer >::const_iterator end = TimedEventsManager::managers[&scene].timedEvents.end();
        for (std::map < gd::String, ManualTimer >::iterator iter = TimedEventsManager::managers[&scene].timedEvents.begin();iter != end;++iter)
        {
            if ( propertyNb == i )
            {
                name = iter->first;
                //Unmangle name
                if ( name.find("GDNamedTimedEvent_") == 0 && name.length() > 18 )
                    name = name.substr(18, name.length());
                else
                    name = _("No name");

                value = gd::String::From(static_cast<double>(iter->second.GetTime())/1000000.0)+"s";

                return;
            }

            ++i;
        }
    }