Exemple #1
0
void Thumb::init(xml::node& node)
{
	ImageButton::init(node);
	
	xml::node setting = node("TrackArea");
	if(!setting.empty())
	{
		setTrackarea(StringToArea(setting.first_child().value()));
	}

	setting = node("Horizontal");
	if(!setting.empty())
	{
		m_horiz = StringToBool(setting.first_child().value());
	}

	setting = node("Progress");
	if(!setting.empty())
	{
		setProgress((float)atof(setting.first_child().value()));
	}

	setting = node("Movable");
	if(!setting.empty())
	{
		m_movable = StringToBool(setting.first_child().value());
	}
}
Exemple #2
0
WOGBallStrand* OGBallConfig::CreateStrand_(const QDomElement & element)
{
    WOGBallStrand* obj = new WOGBallStrand;

    obj->burntimage = element.attribute("burntimage");
    obj->fireparticles = element.attribute("fireparticles");
    obj->image = element.attribute("image");
    obj->inactiveimage = element.attribute("inactiveimage");
    obj->type = element.attribute("type");

    obj->burnspeed = element.attribute("burnspeed", "0").toFloat();
    obj->dampfac = element.attribute("dampfac", "0").toFloat();
    obj->ignitedelay = element.attribute("ignitedelay", "0").toFloat();
    obj->maxforce = element.attribute("maxforce", "0").toFloat();
    obj->maxlen1 = element.attribute("maxlen1", "0").toFloat();
    obj->maxlen2 = element.attribute("maxlen2", "0").toFloat();
    obj->minlen = element.attribute("minlen", "0").toFloat();
    obj->shrinklen = element.attribute("shrinklen", "140").toFloat();
    obj->springconstmax = element.attribute("springconstmax").toFloat();
    obj->springconstmin = element.attribute("springconstmin").toFloat();
    obj->thickness = element.attribute("thickness").toFloat();

    obj->rope = StringToBool(element.attribute("rope"));
    obj->geom = StringToBool(element.attribute("geom"));
    obj->walkable = StringToBool(element.attribute("walkable", "true"));

    return obj;
}
WOGLinearForceField* OGSceneConfig::CreateLinearForceField(const QDomElement &element)
{
    WOGLinearForceField* obj = new WOGLinearForceField;
    obj->type = element.attribute("type");
    obj->force = StringToPoint(element.attribute("force"));
    obj->dampeningfactor = element.attribute("dampeningfactor").toDouble();
    obj->antigrav = StringToBool(element.attribute("antigrav"));
    obj->geomonly = StringToBool(element.attribute("geomonly"));

    return obj;
}
Exemple #4
0
	void FrameWindow::init(xml::node& node)
	{
		Panel::init(node);

		xml::node setting = node("Title");
		if(!setting.empty())
		{
			m_text = setting.first_child().value();
		}

		setting = node("Font");
		if(!setting.empty())
		{
			m_font = m_system.getWindowManager().loadFont(setting.first_child().value());
		}

		setting = node("Formatting");
		if(!setting.empty())
		{
			m_format = StringToFormatType(setting.first_child().value());
		}

		setting = node("CaptionColor");
		if(!setting.empty())
		{
			m_captionColor = StringToColor(setting.first_child().value());
		}
		
		setting = node("Movable");
		if(!setting.empty())
		{
			m_movable = StringToBool(setting.first_child().value());
		}

		setting = node("ClampToScreen");
		if(!setting.empty())
		{
			m_clampToScreen = StringToBool(setting.first_child().value());
		}

		xml::node frame = node("Caption");
		if(!frame.empty())
		{
			std::string setname = frame["Imageset"].value();
			m_imgset = m_system.getWindowManager().loadImageset(setname);
			if(m_imgset)
			{
				const Imageset& set = *m_imgset;
				m_captionBackImg = set[frame("Background")["Image"].value()];
				m_captionLeftImg = set[frame("Left")["Image"].value()];
				m_captionRightImg = set[frame("Right")["Image"].value()];
			}
		}
	}
Exemple #5
0
void OGBallConfig::CreatePlayerInteraction_(WOGBall* ball)
{
    ball->attribute.player.detachable =
            StringToBool(rootElement.attribute("detachable", "true"));

    ball->attribute.player.draggable =
            StringToBool(rootElement.attribute("draggable", "true"));

    ball->attribute.player.hingedrag =
            StringToBool(rootElement.attribute("hingedrag", "false"));

    ball->attribute.player.fling = rootElement.attribute("fling");
}
Exemple #6
0
void InitSettings(void)
{
	char fname[_MAX_FNAME+MAX_PATH], scriptPath[_MAX_PATH],
		defaultStarter[_MAX_FNAME], defaultGame[_MAX_FNAME], debug[6],
		quitOnHostile[6], quitOnError[6], maxGameTime[6], gameTimeout[6],
		startAtMenu[6], disableCache[6], memUsage[6], gamePrint[6],
		useProfilePath[6], logConsole[6], enableUnsupported[6],
		forwardMessageBox[6], consoleFont[6];

	sprintf_s(fname, sizeof(fname), "%sd2bs.ini", Vars.szPath);

	GetPrivateProfileString("settings", "ScriptPath", "scripts", scriptPath, _MAX_PATH, fname);
	GetPrivateProfileString("settings", "DefaultGameScript", "default.dbj", defaultGame, _MAX_FNAME, fname);
	GetPrivateProfileString("settings", "DefaultStarterScript", "starter.dbj", defaultStarter, _MAX_FNAME, fname);
	GetPrivateProfileString("settings", "MaxGameTime", "0", maxGameTime, 6, fname);
	GetPrivateProfileString("settings", "Debug", "false", debug, 6, fname);
	GetPrivateProfileString("settings", "QuitOnHostile", "false", quitOnHostile, 6, fname);
	GetPrivateProfileString("settings", "QuitOnError", "false", quitOnError, 6, fname);
	GetPrivateProfileString("settings", "StartAtMenu", "true", startAtMenu, 6, fname);
	GetPrivateProfileString("settings", "DisableCache", "true", disableCache, 6, fname);
	GetPrivateProfileString("settings", "MemoryLimit", "100", memUsage, 6, fname);
	GetPrivateProfileString("settings", "UseGamePrint", "false", gamePrint, 6, fname);
	GetPrivateProfileString("settings", "GameReadyTimeout", "5", gameTimeout, 6, fname);
	GetPrivateProfileString("settings", "UseProfileScript", "false", useProfilePath, 6, fname);
	GetPrivateProfileString("settings", "LogConsoleOutput", "false", logConsole, 6, fname);
	GetPrivateProfileString("settings", "EnableUnsupported", "false", enableUnsupported, 6, fname);
	GetPrivateProfileString("settings", "ForwardMessageBox", "false", forwardMessageBox, 6, fname);
	GetPrivateProfileString("settings", "ConsoleFont", "0", consoleFont, 6, fname);
	sprintf_s(Vars.szScriptPath, _MAX_PATH, "%s%s", Vars.szPath, scriptPath);
	strcpy_s(Vars.szStarter, _MAX_FNAME, defaultStarter);
	strcpy_s(Vars.szDefault, _MAX_FNAME, defaultGame);

	Vars.dwGameTime = GetTickCount();
	Vars.dwMaxGameTime = abs(atoi(maxGameTime) * 1000);
	Vars.dwGameTimeout = abs(atoi(gameTimeout) * 1000);

	Vars.bQuitOnHostile = StringToBool(quitOnHostile);
	Vars.bQuitOnError = StringToBool(quitOnError);
	Vars.bStartAtMenu = StringToBool(startAtMenu);
	Vars.bDisableCache = StringToBool(disableCache);
	Vars.bUseGamePrint = StringToBool(gamePrint);
	Vars.bUseProfileScript = StringToBool(useProfilePath);
	Vars.bLogConsole = StringToBool(logConsole);
	Vars.bEnableUnsupported = StringToBool(enableUnsupported);
	Vars.bForwardMessageBox = StringToBool(forwardMessageBox);
	Vars.eventSignal = CreateEventA(false, true, false, nullptr);
	Vars.dwMemUsage = abs(atoi(memUsage));
	Vars.dwConsoleFont =  abs(atoi(consoleFont));
	if(Vars.dwMemUsage < 1)
		Vars.dwMemUsage = 50;
	Vars.dwMemUsage *= 1024*1024;
	Vars.oldWNDPROC = NULL;
}
Exemple #7
0
	void BaseList::init(xml::node& node)
	{
		Panel::init(node);

		xml::node setting = node("HasFrame");
		if(!setting.empty())
		{
			m_drawpanel = StringToBool(setting.first_child().value());
		}
		setting = node("Columns");
		if(!setting.empty())
		{
			m_columns = (unsigned int)atoi(setting.first_child().value());
			if(!m_columns)
				m_columns = 1;
		}
		setting = node("ColumnWidth");
		if(!setting.empty())
		{
			m_colWidth = (float)atof(setting.first_child().value());
		}
		setting = node("Borders");
		if(!setting.empty())
		{
			m_borders = StringToRect(setting.first_child().value());
		}
	}
WOGRadialForceField* OGSceneConfig::CreateRadialForceField(const QDomElement &element)
{
    WOGRadialForceField* obj = new WOGRadialForceField;
    obj->id = element.attribute("id");
    obj->type = element.attribute("type");
    obj->center = StringToPoint(element.attribute("center"));
    obj->radius = element.attribute("radius").toDouble();
    obj->forceatcenter = element.attribute("forceatcenter").toDouble();
    obj->forceatedge = element.attribute("forceatedge").toDouble();
    obj->dampeningfactor = element.attribute("dampeningfactor").toDouble();
    obj->antigrav = StringToBool(element.attribute("antigrav"));
    obj->geomonly = StringToBool(element.attribute("geomonly"));
    obj->enabled = StringToBool(element.attribute("enabled"));

    return obj;
}
    /// Create an account
    static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args)
    {
        if (!*args)
            return false;

        ///- %Parse the command line arguments
        char* accountName = strtok((char*)args, " ");
        char* password = strtok(NULL, " ");
        if (!accountName || !password)
            return false;

        if (!strchr(accountName, '@'))
        {
            handler->SendSysMessage(LANG_ACCOUNT_INVALID_BNET_NAME);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* createGameAccountParam = strtok(NULL, " ");
        bool createGameAccount = true;
        if (createGameAccountParam)
            createGameAccount = StringToBool(createGameAccountParam);

        std::string gameAccountName;
        switch (Battlenet::AccountMgr::CreateBattlenetAccount(std::string(accountName), std::string(password), createGameAccount, &gameAccountName))
        {
            case AccountOpResult::AOR_OK:
            {
                if (createGameAccount)
                    handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET_WITH_GAME, accountName, gameAccountName.c_str());
                else
                    handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET, accountName);

                if (handler->GetSession())
                {
                    TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) created Battle.net account %s%s%s",
                        handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
                        handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(),
                        accountName, createGameAccount ? " with game account " : "", createGameAccount ? gameAccountName.c_str() : "");
                }
                break;
            }
            case AccountOpResult::AOR_NAME_TOO_LONG:
                handler->SendSysMessage(LANG_ACCOUNT_NAME_TOO_LONG);
                handler->SetSentErrorMessage(true);
                return false;
            case AccountOpResult::AOR_PASS_TOO_LONG:
                handler->SendSysMessage(LANG_ACCOUNT_PASS_TOO_LONG);
                handler->SetSentErrorMessage(true);
                return false;
            case AccountOpResult::AOR_NAME_ALREADY_EXIST:
                handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
                handler->SetSentErrorMessage(true);
                return false;
            default:
                break;
        }

        return true;
    }
Exemple #10
0
	void ScrollBar::init(xml::node& node)
	{
		Slider::init(node);
		
		xml::node setting = node("Step");
		if(!setting.empty())
		{
			m_step = (float)atof(setting.first_child().value());
		}
		
		setting = node("Horizontal");
		if(!setting.empty())
		{
			m_horiz = StringToBool(setting.first_child().value());
		}

		setting = node("Document");
		if(!setting.empty())
		{
			setDocumentSize((float)atof(setting.first_child().value()));
		}
		xml::node frame = node("Frame");
		if(!frame.empty())
		{
			std::string setname = frame["Imageset"].value();
			m_imgset = m_system.getWindowManager().loadImageset(setname);
			if(m_imgset)
			{
				const Imageset& set = *m_imgset;
				m_backImg = set[frame("Background")["Image"].value()];
				m_leftImg = set[frame("Left")["Image"].value()];
				m_rightImg = set[frame("Right")["Image"].value()];
			}
		}
	}
void ThemeEditorDialog::OnBnClickedButtonLoad()
{
    CString filter = _T("musikCube Theme Files (*.ini)|*.ini||");
    
    FileDialog ofdlg(
        TRUE, 
        _T("ini"), 
        NULL, 
        OFN_EXPLORER | OFN_FILEMUSTEXIST, 
        filter
   );

    if (ofdlg.DoModal() == IDOK)
    {
        std::string fn = musik::Core::utf16to8(ofdlg.GetFileName().GetBuffer(), false);
        CIniFile iniFile(fn);

        if (!iniFile.ReadFile())
        {
            MessageBox(
                _T("Failed to read theme file from disk.  Invalid access rights?"),
                _T("musikCube"),
                MB_OK | MB_ICONERROR
           );

            return;
        }

        Globals::Preferences->MUSIK_COLOR_ACTIVECAPTION = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Active Caption", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_CAPTIONTEXT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Active Caption Text", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_INACTIVECAPTION = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Inactive Caption", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_INACTIVECAPTIONTEXT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Inactive Caption Text", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_BTNFACE = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Button Face", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_BTNTEXT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Button Text", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_BTNHILIGHT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Button Hilight", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_BTNSHADOW = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Button Shadow", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_LISTCTRL = 
            StringToCOLORREF(iniFile.GetValue("Theme", "List", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_LISTCTRLTEXT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "List Text", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_HIGHLIGHT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Highlight", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->MUSIK_COLOR_HIGHLIGHTTEXT = 
            StringToCOLORREF(iniFile.GetValue("Theme", "Highlight Text", COLORREFToString(AUTOMATIC_COLOR)));
        Globals::Preferences->SetUseLightIconTheme(
            StringToBool(iniFile.GetValue("Theme", "Use Light Icons", BoolToString(false))));

        this->ReloadColors();
        AfxGetApp()->GetMainWnd()->SendMessage(WM_SYSCOLORCHANGE);
    }
}
Exemple #12
0
void CMusikPrefs::LoadPrefs()
{
	// main dialog
	m_Dlg_Size		= StringToCSize( config->GetValue( "Dialog", "Dialog Size", "800x600" ) );
	m_Dlg_Pos		= StringToCPoint( config->GetValue( "Dialog", "Dialog Position", "50,50" ) );
	m_Dlg_Maximized	= StringToBool( config->GetValue( "Dialog", "Maximized", "0" ) );
	m_Dlg_ResetUI	= StringToBool( config->GetValue( "Dialog", "Reset UI", "1" ) );

	// selection area
	m_SelectionBox_Count = StringToInt( config->GetValue( "Selection Area", "Count", "2" ) );

	// playlist
	m_Playlist_Order		= StringToCIntArray( config->GetValue( "Playlist", "Column Order", GetDefPlaylistOrder() ) );
	m_Playlist_Sizes		= StringToCIntArray( config->GetValue( "Playlist", "Column Sizes", GetDefPlaylistSizes() ) );

	// now playing
	m_NowPlaying_CaptionFont = StringToInt( config->GetValue( "Now Playing", "Caption Font Size", "11" ) );
	
	// player
	m_Player_Driver			= StringToInt( config->GetValue( "Player", "Driver", "0" ) );
	m_Player_Device			= StringToInt( config->GetValue( "Player", "Device", "0" ) );
	m_Player_Rate			= StringToInt( config->GetValue( "Player", "Rate", "44100" ) );
	m_Player_Max_Channels	= StringToInt( config->GetValue( "Player", "Maximum Channels", "6" ) );

	// crossfader
	m_Crossfader_Enabled	= StringToBool( config->GetValue( "Crossfader", "Enabled", "1" ) );
	m_Crossfader_Current	= config->GetValue( "Crossfader", "Set Name", "Default" );
	m_Crossfader_Default	= StringToCrossfader( config->GetValue( "Crossfader", "Values", "2.0,0.5,1.0,3.0" ) );

	// dialog colors
	MUSIK_COLOR_ACTIVECAPTION		= StringToCOLORREF( config->GetValue( "Dialog Colors", "Active Caption", "255,0,255" ) );
	MUSIK_COLOR_CAPTIONTEXT			= StringToCOLORREF( config->GetValue( "Dialog Colors", "Active Caption Text", "255,0,255" ) );
	MUSIK_COLOR_INACTIVECAPTION		= StringToCOLORREF( config->GetValue( "Dialog Colors", "Inactive Caption", "255,0,255" ) );
	MUSIK_COLOR_INACTIVECAPTIONTEXT	= StringToCOLORREF( config->GetValue( "Dialog Colors", "Inactive Caption Text", "255,0,255" ) );
	MUSIK_COLOR_BTNFACE				= StringToCOLORREF( config->GetValue( "Dialog Colors", "Button Face", "255,0,255" ) );
	MUSIK_COLOR_BTNTEXT				= StringToCOLORREF( config->GetValue( "Dialog Colors", "Button Text", "255,0,255" ) );
	MUSIK_COLOR_BTNHILIGHT			= StringToCOLORREF( config->GetValue( "Dialog Colors", "Button Highlight", "255,0,255" ) );
	MUSIK_COLOR_BTNSHADOW			= StringToCOLORREF( config->GetValue( "Dialog Colors", "Button Shadow", "255,0,255" ) );
	MUSIK_COLOR_LISTCTRL			= StringToCOLORREF( config->GetValue( "Dialog Colors", "List Background", "255,0,255" ) );
	MUSIK_COLOR_LISTCTRLTEXT		= StringToCOLORREF( config->GetValue( "Dialog Colors", "List Text", "255,0,255" ) );
	MUSIK_COLOR_HIGHLIGHT			= StringToCOLORREF( config->GetValue( "Dialog Colors", "Color Highlight", "255,0,255" ) );
	MUSIK_COLOR_HIGHLIGHTTEXT		= StringToCOLORREF( config->GetValue( "Dialog Colors", "Color Highlight Text", "255,0,255" ) );

	ParseColors();
}
Exemple #13
0
WOGLabel* OGSceneConfig::CreateLabel(const QDomElement &element)
{
    WOGLabel* obj = new WOGLabel;
    obj->id = element.attribute("id");
    obj->depth = element.attribute("depth").toDouble();
    obj->position = StringToPoint(element.attribute("x")
                                  , element.attribute("y"));

    obj->align = element.attribute("align");
    obj->rotation = element.attribute("rotation").toDouble();
    obj->scale = element.attribute("scale").toDouble();
    obj->overlay = StringToBool(element.attribute("overlay"));
    obj->screenspace = StringToBool(element.attribute("screenspace"));
    obj->font = element.attribute("font");
    obj->text = element.attribute("text");

    return obj;
}
Exemple #14
0
void SPIDevice::PopulateWriterOptions(SPIWriter::Options *options) {
  uint32_t spi_speed;
  if (StringToInt(m_preferences->GetValue(SPISpeedKey()), &spi_speed)) {
    options->spi_speed = spi_speed;
  }
  bool ce_high;
  if (StringToBool(m_preferences->GetValue(SPICEKey()), &ce_high)) {
    options->cs_enable_high = ce_high;
  }
}
bool CWidgetDisplay::InternalLoadFromXml(xmlNode* pSettingsXml, CHTString& rsError)
{
   AdvanceToElementNode(pSettingsXml);
   while (pSettingsXml)
   {
      CHTString sNodeName = (char*)pSettingsXml->name;
      if (IsSameNoCase(sNodeName, "widget"))
      {
         if (!m_pWidgetManager->LoadWidgetSettings(pSettingsXml->children, m_pEngine, rsError))
            return false;
      }
      else if (IsSameNoCase(sNodeName, "clearscreen"))
      {
         if (!StringToBool((char*)pSettingsXml->children->content, m_bClearBackground))
         {
            rsError = "The clearscreen setting was not specified correctly.";
            return false;
         }
      }
      else if (IsSameNoCase(sNodeName, "include"))
      {
         CHTString sIncludeFile = (char*)pSettingsXml->children->content;
         MungerDataFilePath(sIncludeFile);
         xmlDocPtr pDoc = xmlReadFile(sIncludeFile, NULL, 0);
         if (pDoc == NULL)
         {
            rsError = "Unable to open include file " + sIncludeFile + ".";
            return false;
         }
         xmlNodePtr pIncludeRoot = xmlDocGetRootElement(pDoc);
         if (!IsSameNoCase((char*)pIncludeRoot->name, "include"))
         {
            xmlFreeDoc(pDoc);
            rsError = "<include> element must be root element.";
            return false;
         }
         if (!InternalLoadFromXml(pIncludeRoot->children, rsError))
         {
            xmlFreeDoc(pDoc);
            return false;
         }
         xmlFreeDoc(pDoc);
      }
      else
      {
         cout << "Unrecognized display xml node: " << sNodeName << endl;
         return false;
      }

      pSettingsXml = pSettingsXml->next;
      AdvanceToElementNode(pSettingsXml);
   }

   return true;
}
Exemple #16
0
void InverseOrSetBool(bool& container, const std::string& argValue, const bool inverseArg)
{
	if (argValue.empty()) {
		// toggle
		container = !container;
	} else {
		// set
		const bool value = StringToBool(argValue);
		container = inverseArg ? (!value) : (value);
	}
}
bool CAIInterfaceLibraryInfo::IsLookupSupported() const {

	bool lookupSupported = false;

	const std::string& lookupSupportedStr = GetInfo(AI_INTERFACE_PROPERTY_SUPPORTS_LOOKUP);
	if (lookupSupportedStr != DEFAULT_VALUE) {
		lookupSupported = StringToBool(lookupSupportedStr);
	}

	return lookupSupported;
}
Exemple #18
0
WOGBallInstance* OGLevelConfig::CreateBallInstance(const QDomElement &element)
{
    WOGBallInstance* obj = new WOGBallInstance;
    obj->type = element.attribute("type");
    obj->x = element.attribute("x").toFloat();
    obj->y = element.attribute("y").toFloat();

    obj->id = element.attribute("id");
    obj->angle = element.attribute("angle").toFloat();
    obj->discovered = StringToBool(element.attribute("discovered"));

    return obj;
}
Exemple #19
0
WOGLevel* OGLevelConfig::Parser()
{
    WOGLevel* level = new WOGLevel;

    level->ballsrequired = rootElement.attribute("ballsrequired").toInt();
    level->letterboxed = StringToBool(rootElement.attribute("letterboxed"));
    level->visualdebug = StringToBool(rootElement.attribute("visualdebug"));
    level->autobounds = StringToBool(rootElement.attribute("autobounds"));
    level->textcolor = StringToColor(rootElement.attribute("textcolor"));
    level->texteffects = StringToBool(rootElement.attribute("texteffects"));
    level->timebugprobability =
        rootElement.attribute("timebugprobability").toDouble();

    level->strandgeom = StringToBool(rootElement.attribute("strandgeom"));
    level->allowskip = StringToBool(rootElement.attribute("allowskip"));

    QDomNode node = rootElement.firstChild();

    while (!node.isNull())
    {
        QDomElement domElement = node.toElement();

        if (domElement.tagName() == "camera")
        {
            level->camera << CreateCamera(domElement);
        }
        else if (domElement.tagName() == "music")
        {
            level->music.id = domElement.attribute("music");
        }
        else if (domElement.tagName() == "BallInstance")
        {
            level->ball << CreateBallInstance(domElement);
        }
        else if (domElement.tagName() == "levelexit")
        {
            if (!level->levelexit)
            {
                level->levelexit = CreateLevelExit(domElement);
            }
        }
        else if (domElement.tagName() == "pipe")
        {
            if (!level->pipe)
            {
                level->pipe = CreatePipe(domElement);
            }
        }
        else if (domElement.tagName() == "Strand")
        {
            level->strand << CreateStrand(domElement);
        }

        node = node.nextSibling();
    }

    return level;
}
Exemple #20
0
void OGSceneConfig::CreatePObject(WOGPObject* pobject
                                  , const QDomElement &element)
{
    pobject->id = element.attribute("id");

    if (StringToBool(element.attribute("static")))
    {
        pobject->dynamic = false;
    }
    else { pobject->dynamic = true; }

    pobject->tag = element.attribute("tag", "walkable");
    pobject->material = element.attribute("material");
}
///////////////////////////////////////////////////////////////
//
// CResource::GetAclRequests
//
// Get all acl requests for this resource
//
///////////////////////////////////////////////////////////////
void CResource::GetAclRequests ( std::vector < SAclRequest >& outResultList )
{
    outResultList.clear ();

    CAccessControlList* pAutoAcl = FindAutoAcl ();
    if ( !pAutoAcl )
        return;

    // Get each right
    for ( std::list < CAccessControlListRight* >::const_iterator iter = pAutoAcl->IterBegin () ; iter != pAutoAcl->IterEnd () ; ++iter )
    {
        CAccessControlListRight* pAclRight = *iter;

        // Create SAclRequest from ACL
        SAclRequest request ( CAclRightName ( pAclRight->GetRightType (), pAclRight->GetRightName () ) );
        request.bAccess = StringToBool ( pAclRight->GetAttributeValue ( "access" ) );
        request.bPending = StringToBool ( pAclRight->GetAttributeValue ( "pending" ) );
        request.strWho = pAclRight->GetAttributeValue ( "who" );
        request.strDate = pAclRight->GetAttributeValue ( "date" );

        outResultList.push_back ( request );
    }
}
map<string, bool> Config::ReadAssoc(std::string key, map<string, bool> &value) {

	for (map<string, ConfigEntry>::iterator it = contents.begin(); it != contents.end(); it++) {
		if (!(*it).first.find(key + "[")) {
			pair<string, bool> assoc;
			assoc.first = (*it).first.substr((*it).first.find("[") + 1, (*it).first.length() - (*it).first.find("[") - 2);
			transform(assoc.first.begin(), assoc.first.end(), assoc.first.begin(), ::tolower);

			if (value.find(assoc.first) == value.end()) {
				assoc.second = StringToBool((*it).second.value);
				value.insert(assoc);
			}
			else {
				value[assoc.first] = StringToBool((*it).second.value);
			}

			(*it).second.pointer = &value;
			(*it).second.type = CTAssocBool;
		}
	}

	return value;
}
///////////////////////////////////////////////////////////////
//
// CResource::FindAclRequest
//
// Will fail if right does not have a pending attribute
//
///////////////////////////////////////////////////////////////
bool CResource::FindAclRequest ( SAclRequest& result )
{
    if ( !FindAutoAcl () )
        return false;

    CAccessControlListRight* pAclRight = GetAutoAcl ()->GetRight ( result.rightName.GetName (), result.rightName.GetType () );
    if ( !pAclRight )
        return false;

    // Fill SAclRequest
    result.bAccess = StringToBool ( pAclRight->GetAttributeValue ( "access" ) );
    result.bPending = StringToBool ( pAclRight->GetAttributeValue ( "pending" ) );
    result.strWho = pAclRight->GetAttributeValue ( "who" );
    result.strDate = pAclRight->GetAttributeValue ( "date" );

    // Ensure not pending and allow
    if ( result.bPending && result.bAccess )
    {
        result.bAccess = false;
        CommitAclRequest ( result );
    }

    return pAclRight->GetAttributeValue ( "pending" ) != "";
}
Exemple #24
0
static void SetPropValue( CMFCPropertyGridProperty* pProp, const FieldInfo& info, const CString& value )
{
    switch( info.m_dt )
    {
    case DT_STRING:
        pProp->SetValue( ( COleVariant )value );
        break;

    case DT_INT:
        pProp->SetValue( ( long )_ttoi( value ) );
        break;

    case DT_NUMERIC:
        pProp->SetValue( _tstof( value ) );
        break;

    case DT_BOOL:
        pProp->SetValue( ( long )( StringToBool( value ) ? 1 : 0 ) );
        break;

    case DT_DATE:
    {
        COleDateTime dt;
        StringToDataTime( value, dt );
        pProp->SetValue( ( COleVariant )dt );
    }
    break;

    case DT_LIST:
        if( info.m_lt == LT_STRING )
        {
            pProp->SetValue( ( COleVariant )value );
        }
        else if( info.m_lt == LT_INT )
        {
            pProp->SetValue( ( long )_ttoi( value ) );
        }
        else if( info.m_lt == LT_OBJECT )
        {
            pProp->SetValue( ( COleVariant )value );
        }
        break;

    default:
        pProp->SetValue( ( COleVariant )value ); // 默认为字符串类型
        break;
    }
}
/* ReadToggle(std::string key, std::string toggle, bool state)
*	Reads in a toggle from the key->pair
*	Config Example:
*		Key: True, VK_A
*/
Toggle Config::ReadToggle(std::string key, std::string toggle, bool state, Toggle& value) {
	//Check if configuration value exists.
	Toggle ret;
	if (contents.find(key) == contents.end()) {
		contents[key].key = key;
		contents[key].value = ((state) ? "True, " : "False, ") + toggle;
	}

	contents[key].toggle = &value;
	contents[key].type = CTToggle;

	ret.toggle = GetKeyCode(Trim(contents[key].value.substr(contents[key].value.find_first_of(",") + 1)).c_str()).value;
	ret.state = StringToBool(Trim(contents[key].value.substr(0, contents[key].value.find_first_of(","))));

	value = ret;
	return ret;
}
HRESULT SetBoolProperty(bool &dest, const PROPVARIANT &value)
{
  switch(value.vt)
  {
    case VT_EMPTY:
      dest = true;
      return S_OK;
    case VT_BOOL:
      dest = (value.boolVal != VARIANT_FALSE);
      return S_OK;
    /*
    case VT_UI4:
      dest = (value.ulVal != 0);
      break;
    */
    case VT_BSTR:
      return StringToBool(value.bstrVal, dest) ?  S_OK : E_INVALIDARG;
  }
  return E_INVALIDARG;
}
Exemple #27
0
	void Label::init(xml::node& node)
	{
		base_window::init(node);

		xml::node setting = node("Font");
		if(!setting.empty())
		{
			m_font = m_system.getWindowManager().loadFont(setting.first_child().value());
			m_shadow_enabled = setting["shadow"].as_bool();
			m_shadow_scale = StringToSize(setting["shadow_scale"].value());
			m_shadow_offset = StringToPoint(setting["shadow_offset"].value());
		}

		setting = node("Formatting");
		if(!setting.empty())
		{
			m_format = StringToFormatType(setting.first_child().value());
		}

		setting = node("Spacing");
		if(!setting.empty())
		{
			m_spacing = (float)atof(setting.first_child().value());
			if(m_font)
				m_font->setSpacing(m_spacing);
		}

		setting = node("Centred");
		if(!setting.empty())
		{
			m_centred = StringToBool(setting.first_child().value());
		}

		setting = node("Text");
		if(!setting.empty())
		{
			m_text = setting.first_child().value();
		}
	}
Exemple #28
0
void ProgressBar::init(xml::node& node)
{
	Progress::init(node);
	xml::node setting = node("Signed");
	if(!setting.empty())
	{
		m_signed = StringToBool(setting.first_child().value());
	}
	xml::node frame = node("Bar");
	if(!frame.empty())
	{
		std::string setname = frame["Imageset"].value();
		m_imgset = m_system.getWindowManager().loadImageset(setname);
		if(m_imgset)
		{
			const Imageset& set = *m_imgset;
			m_backImg = set[frame("Background")["Image"].value()];
			m_leftImg = set[frame("Left")["Image"].value()];
			m_rightImg = set[frame("Right")["Image"].value()];
		}
	}
}
Exemple #29
0
bool ParseBoolArgument(int argc,
                       char* argv[],
                       int& currentIndex,
                       bool& value)
{
  int parameterIndex=currentIndex;
  int argumentIndex=currentIndex+1;

  currentIndex+=2;

  if (argumentIndex>=argc) {
    std::cerr << "Missing parameter after option '" << argv[parameterIndex] << "'" << std::endl;
    return false;
  }

  if (!StringToBool(argv[argumentIndex],
                    value)) {
    std::cerr << "Cannot parse argument for parameter '" << argv[parameterIndex] << "'" << std::endl;
    return false;
  }

  return true;
}
Exemple #30
0
bool Ini::Load(wxString key, const bool def_value)
{
	return StringToBool(m_Config->Read(key, BoolToString(def_value)));
}