Ejemplo n.º 1
0
void Clear ( const std::string& key )
{
	PreferenceMap::iterator iter = preferences.find(key);
	if (iter != preferences.end())
	{
		preferences.erase(iter);
	}
}
Ejemplo n.º 2
0
void Save ()
{
	std::string buffer;
	for ( PreferenceMap::iterator iter = preferences.begin(); iter != preferences.end(); iter++ )
	{
		buffer.append(iter->first + ":" + iter->second + "\n");
	}
	ResourceManager::WriteFile("Config/Preferences.cfg", buffer.data(), buffer.length());
	ResourceManager::WriteFile("Config/Preferences.cfg", buffer.data(), sizeof(buffer.data()));
}
Ejemplo n.º 3
0
// New functions
void InheritanceVectorPart::InitializeEx(CComPtr<IMgaProject>& pProject, CComPtr<IMgaMetaPart>& pPart, CComPtr<IMgaFCO>& pFCO,
									  HWND parentWnd, PreferenceMap& preferences)
{
	TriangleVectorPart::InitializeEx(pProject, pPart, pFCO, parentWnd, preferences);

	if (m_inheritanceType == ImplementationInheritance || m_inheritanceType == InterfaceInheritance) {
		getFacilities().getMetaFCO(pPart, m_spMetaFCO);
		bool bColor = false;
		COLORREF crColor = COLOR_BLACK;
		PreferenceMap::iterator it = preferences.find(PREF_COLOR);
		if (it != preferences.end()) {
			bColor = true;
			crColor = it->second.uValue.crValue;
		} else {
			bColor = getFacilities().getPreference(pFCO, m_spMetaFCO, PREF_COLOR, crColor);
		}
		AbsoluteCoordCommand* colorCmd = new AbsoluteCoordCommand(crColor);
		AbsoluteCoordCommand* grayedCmd = new AbsoluteCoordCommand(COLOR_GRAYED_OUT);
		m_coordCommands.push_back(colorCmd);
		m_coordCommands.push_back(grayedCmd);
		unsigned long size = m_coordCommands.size();
		AddCommand(VectorCommand(colorCmd, grayedCmd, VectorCommand::SelectBrush));

		// Add four coordinates for the inner circle boundaries
		ComplexCoordCommand* ellipseLeft = new ComplexCoordCommand(LeftMost, 0.5 - 0.25 * INHERITANCE_RATIO);
		ellipseLeft->AddCommand(RightMost, 0.5 + 0.25 * INHERITANCE_RATIO, CoordAdd);
		ellipseLeft->AddCommand(OneConstant, 1.0, CoordAdd);	// correction in case of small sizes
		ComplexCoordCommand* ellipseTop = new ComplexCoordCommand(TopMost, 1.0 / 3.0 - 0.25);
		ellipseTop->AddCommand(BottomMost, 2.0 / 3.0 + 0.25, CoordAdd);
		ComplexCoordCommand* ellipseRight = new ComplexCoordCommand(LeftMost, 0.5 + 0.25 * INHERITANCE_RATIO);
		ellipseRight->AddCommand(RightMost, 0.5 - 0.25 * INHERITANCE_RATIO, CoordAdd);
		ComplexCoordCommand* ellipseBottom = new ComplexCoordCommand(TopMost, 1.0 / 3.0 + 0.25);
		ellipseBottom->AddCommand(BottomMost, 2.0 / 3.0 - 0.25, CoordAdd);

		m_coordCommands.push_back(ellipseLeft);
		m_coordCommands.push_back(ellipseTop);
		m_coordCommands.push_back(ellipseRight);
		m_coordCommands.push_back(ellipseBottom);
		size = m_coordCommands.size();
		if (m_inheritanceType == InterfaceInheritance)
			AddCommand(VectorCommand(m_coordCommands[size - 4],
									 m_coordCommands[size - 3],
									 m_coordCommands[size - 2],
									 m_coordCommands[size - 1],
									 VectorCommand::DrawEllipse));
		if (m_inheritanceType == ImplementationInheritance)
			AddCommand(VectorCommand(m_coordCommands[size - 4],
									 m_coordCommands[size - 3],
									 m_coordCommands[size - 2],
									 m_coordCommands[size - 1],
									 VectorCommand::FillEllipse));
	}
}
Ejemplo n.º 4
0
std::string Get ( const std::string& key, const std::string& defaultValue )
{
	PreferenceMap::iterator iter = preferences.find(key);
	if (iter == preferences.end())
	{
		return defaultValue;
	}
	else
	{
		return iter->second;
	}
}
Ejemplo n.º 5
0
void PartBase::InitializeEx(CComPtr<IMgaProject>& pProject, CComPtr<IMgaMetaPart>& pPart, CComPtr<IMgaFCO>& pFCO,
							HWND parentWnd, PreferenceMap& preferences)
{
	m_parentWnd = parentWnd;
	Initialize(pProject, pPart, pFCO);

	// HasViolations
	if (m_spFCO) {
		PreferenceMap::iterator it = preferences.find(PREF_VIOLATED);
		if (it != preferences.end())
			m_bHasViolation = it->second.uValue.bValue;
		else
			m_bHasViolation = getFacilities().getPreferenceStatus(m_spFCO, PREF_VIOLATED) == PS_HERE;

		it = preferences.find(PREF_ITEMRESIZABLE);
		if (it != preferences.end())
			m_bResizable = it->second.uValue.bValue;
		else
			getFacilities().getPreference(m_spFCO, PREF_ITEMRESIZABLE, m_bResizable);
	} else {
		PreferenceMap::iterator it = preferences.find(PREF_ITEMSHADOWCAST);
		if (it == preferences.end())
			preferences[PREF_ITEMSHADOWCAST] = PreferenceVariant(false);
		it = preferences.find(PREF_ITEMRESIZABLE);
		if (it == preferences.end())
			preferences[PREF_ITEMRESIZABLE] = PreferenceVariant(false);
	}

	m_lBorderWidth = 0;
}
Ejemplo n.º 6
0
void Load ()
{
	preferences.clear();
	SDL_RWops* ops = ResourceManager::OpenFile("Config/Preferences.cfg");
	if (!ops)
		return;
	size_t len;
	char* buffer = (char*)ResourceManager::ReadFull(&len, ops, 1);
	std::string preferenceLine;
	char* tempPointer = buffer;
	while (*tempPointer)
	{
		char ch = *tempPointer;
		if (ch == '\n')
		{
			ParseLine(preferenceLine);
			preferenceLine.clear();
		}
		else
		{
			preferenceLine.push_back(ch);
		}
		tempPointer++;
	}
	free((void*)buffer);
}
Ejemplo n.º 7
0
namespace Preferences
{

typedef std::map<std::string, std::string> PreferenceMap;
PreferenceMap preferences;

std::string Get ( const std::string& key, const std::string& defaultValue )
{
	PreferenceMap::iterator iter = preferences.find(key);
	if (iter == preferences.end())
	{
		return defaultValue;
	}
	else
	{
		return iter->second;
	}
}

void Set ( const std::string& key, const std::string& defaultValue )
{
	preferences[key] = defaultValue;
}

void Clear ( const std::string& key )
{
	PreferenceMap::iterator iter = preferences.find(key);
	if (iter != preferences.end())
	{
		preferences.erase(iter);
	}
}

static void ParseLine ( const std::string& line )
{
	if (line != "")
	{
		std::string::size_type n = line.find_first_of(':');
		std::string k = line.substr(0, n);
		std::string v = line.substr(n + 1, std::string::npos);
		preferences[k] = v;
	}
}

void Load ()
{
	preferences.clear();
	SDL_RWops* ops = ResourceManager::OpenFile("Config/Preferences.cfg");
	if (!ops)
		return;
	size_t len;
	char* buffer = (char*)ResourceManager::ReadFull(&len, ops, 1);
	std::string preferenceLine;
	char* tempPointer = buffer;
	while (*tempPointer)
	{
		char ch = *tempPointer;
		if (ch == '\n')
		{
			ParseLine(preferenceLine);
			preferenceLine.clear();
		}
		else
		{
			preferenceLine.push_back(ch);
		}
		tempPointer++;
	}
	free((void*)buffer);
}

void Save ()
{
	std::string buffer;
	for ( PreferenceMap::iterator iter = preferences.begin(); iter != preferences.end(); iter++ )
	{
		buffer.append(iter->first + ":" + iter->second + "\n");
	}
	ResourceManager::WriteFile("Config/Preferences.cfg", buffer.data(), buffer.length());
	ResourceManager::WriteFile("Config/Preferences.cfg", buffer.data(), sizeof(buffer.data()));
}

}