diff options
| -rw-r--r-- | Plugins/skins/Docs/skins_changelog.txt | 1 | ||||
| -rw-r--r-- | Plugins/skins/SkinLib/DialogInfo.cpp | 190 | ||||
| -rw-r--r-- | Plugins/skins/SkinLib/DialogInfo.h | 50 | ||||
| -rw-r--r-- | Plugins/skins/ZIP/doit.bat | 4 | 
4 files changed, 245 insertions, 0 deletions
| diff --git a/Plugins/skins/Docs/skins_changelog.txt b/Plugins/skins/Docs/skins_changelog.txt index b2d58ce..584655e 100644 --- a/Plugins/skins/Docs/skins_changelog.txt +++ b/Plugins/skins/Docs/skins_changelog.txt @@ -7,6 +7,7 @@ Changelog:    + Added valign (not used yet)
    + Added dialog info (allow clients to set script variables starting with info)
    + The zip will contain also the pdbs (at least until it is more stable)
 +  * Fix for ASCII strings
  . 0.0.0.1
    + Initial version
\ No newline at end of file diff --git a/Plugins/skins/SkinLib/DialogInfo.cpp b/Plugins/skins/SkinLib/DialogInfo.cpp new file mode 100644 index 0000000..fd29a37 --- /dev/null +++ b/Plugins/skins/SkinLib/DialogInfo.cpp @@ -0,0 +1,190 @@ +#include "globals.h"
 +#include "DialogInfo.h"
 +#include "tstring.h"
 +
 +class DialogInfoValue
 +{
 +public:
 +	DialogInfoValue(const char *aName) : name(aName), type(UNKNOWN) {}
 +
 +	const char * getName() { return name.c_str(); }
 +
 +	void set(const TCHAR *value) { valueString = value; type = TYPE_STRING; }
 +	void set(int value) { valueInt = value; type = TYPE_INT; }
 +	void set(double value) { valueDouble = value; type = TYPE_DOUBLE; }
 +	void set(bool value) { valueBool = value; type = TYPE_BOOL; }
 +
 +	DialogInfoType getType() { return type; }
 +
 +	const TCHAR * getAsString() { return valueString.c_str(); }
 +	int getAsInt() { return valueInt; }
 +	double getAsDouble() { return valueDouble; }
 +	bool getAsBool() { return valueBool; }
 +
 +private:
 +	std::string name;
 +
 +	DialogInfoType type;
 +
 +	std::tstring valueString;
 +	int valueInt;
 +	double valueDouble;
 +	bool valueBool;
 +};
 +
 +DialogInfo::DialogInfo()
 +{
 +}
 +
 +DialogInfo::~DialogInfo()
 +{
 +	for(size_t i = 0; i < values.size(); ++i)
 +		delete values[i];
 +}
 +
 +
 +void DialogInfo::set(const char *name, const TCHAR *value)
 +{
 +	bool isVar;
 +	DialogInfoValue * val = findValue(name, true, &isVar);
 +
 +	if (isVar)
 +		return;
 +
 +	val->set(value);
 +}
 +
 +void DialogInfo::set(const char *name, int value)
 +{
 +	bool isVar;
 +	DialogInfoValue * val = findValue(name, true, &isVar);
 +
 +	if (isVar)
 +		return;
 +
 +	val->set(value);
 +}
 +
 +void DialogInfo::set(const char *name, double value)
 +{
 +	bool isVar;
 +	DialogInfoValue * val = findValue(name, true, &isVar);
 +
 +	if (isVar)
 +		return;
 +
 +	val->set(value);
 +}
 +
 +void DialogInfo::set(const char *name, bool value)
 +{
 +	bool isVar;
 +	DialogInfoValue * val = findValue(name, true, &isVar);
 +
 +	if (isVar)
 +		return;
 +
 +	val->set(value);
 +}
 +
 +void DialogInfo::remove(const char *name)
 +{
 +	size_t len = strlen(name);
 +
 +	for(std::vector<DialogInfoValue *>::iterator it = values.begin(); it != values.end(); )
 +	{
 +		DialogInfoValue *val = *it;
 +
 +		if (stricmp(name, val->getName()) == 0)
 +			it = values.erase(it);
 +		
 +		else if (strnicmp(name, val->getName(), len) == 0 && val->getName()[len] == '.')
 +			it = values.erase(it);
 +		
 +		else
 +			it++;
 +	}
 +}
 +
 +DialogInfoType DialogInfo::getType(const char *name)
 +{
 +	bool isVar;
 +	DialogInfoValue * val = findValue(name, false, &isVar);
 +
 +	if (isVar)
 +		return TYPE_VARIABLE;
 +
 +	else if (val == NULL)
 +		return UNKNOWN;
 +
 +	else
 +		return val->getType();
 +}
 +
 +
 +const TCHAR * DialogInfo::getAsString(const char *name)
 +{
 +	DialogInfoValue * val = findValue(name);
 +	if (val == NULL)
 +		return NULL;
 +	
 +	return val->getAsString();
 +}
 +
 +int DialogInfo::getAsInt(const char *name)
 +{
 +	DialogInfoValue * val = findValue(name);
 +	if (val == NULL)
 +		return 0;
 +	
 +	return val->getAsInt();
 +}
 +
 +double DialogInfo::getAsDouble(const char *name)
 +{
 +	DialogInfoValue * val = findValue(name);
 +	if (val == NULL)
 +		return 0;
 +	
 +	return val->getAsDouble();
 +}
 +
 +bool DialogInfo::getAsBool(const char *name)
 +{
 +	DialogInfoValue * val = findValue(name);
 +	if (val == NULL)
 +		return false;
 +	
 +	return val->getAsBool();
 +}
 +
 +DialogInfoValue * DialogInfo::findValue(const char *name, bool create, bool *isVar)
 +{
 +	size_t len = strlen(name);
 +
 +	if (isVar != NULL) *isVar = false;
 +
 +	for(size_t i = 0; i < values.size(); ++i)
 +	{
 +		DialogInfoValue *val = values[i];
 +
 +		if (stricmp(name, val->getName()) == 0)
 +		{
 +			return val;
 +		}
 +		else if (strnicmp(name, val->getName(), len) == 0 && val->getName()[len] == '.')
 +		{
 +			if (isVar != NULL) *isVar = true;
 +			return val;
 +		}
 +	}
 +
 +	if (create)
 +	{
 +		DialogInfoValue *ret = new DialogInfoValue(name);
 +		values.push_back(ret);
 +		return ret;
 +	}
 +
 +	return NULL;
 +}
 diff --git a/Plugins/skins/SkinLib/DialogInfo.h b/Plugins/skins/SkinLib/DialogInfo.h new file mode 100644 index 0000000..02f0731 --- /dev/null +++ b/Plugins/skins/SkinLib/DialogInfo.h @@ -0,0 +1,50 @@ +#ifndef __DIALOG_INFO_H__
 +# define __DIALOG_INFO_H__
 +
 +#include <windows.h>
 +#include <vector>
 +
 +
 +enum DialogInfoType
 +{
 +	UNKNOWN = 0,
 +	TYPE_VARIABLE,
 +	TYPE_INT,
 +	TYPE_DOUBLE,
 +	TYPE_BOOL,
 +	TYPE_STRING
 +};
 +
 +
 +class DialogInfoValue;
 +
 +class DialogInfo
 +{
 +public:
 +	DialogInfo();
 +	~DialogInfo();
 +
 +	void set(const char *name, const TCHAR *value);
 +	void set(const char *name, int value);
 +	void set(const char *name, double value);
 +	void set(const char *name, bool value);
 +
 +	void remove(const char *name);
 +
 +	DialogInfoType getType(const char *name);
 +
 +	const TCHAR * getAsString(const char *name);
 +	int getAsInt(const char *name);
 +	double getAsDouble(const char *name);
 +	bool getAsBool(const char *name);
 +
 +private:
 +	std::vector<DialogInfoValue *> values; 
 +
 +	DialogInfoValue * findValue(const char *name, bool create = false, bool *isVar = NULL);
 +
 +};
 +
 +
 +
 +#endif // __DIALOG_INFO_H__
\ No newline at end of file diff --git a/Plugins/skins/ZIP/doit.bat b/Plugins/skins/ZIP/doit.bat index 3d1ea7d..a222ed7 100644 --- a/Plugins/skins/ZIP/doit.bat +++ b/Plugins/skins/ZIP/doit.bat @@ -48,7 +48,9 @@ copy "..\Unicode_Release\%name%W.pdb"  mkdir Plugins
  cd Plugins
  copy "..\..\..\..\bin\release unicode\Plugins\%name%W.dll"
 +copy "..\..\Unicode_Release\%name%W.pdb"
  copy "..\..\..\..\bin\release\Plugins\mydetails.dll"
 +copy "..\..\..\mydetails\Release\mydetails.pdb"
  cd ..
  "C:\Program Files\Filzip\Filzip.exe" -a -rp %name%W.zip Plugins Docs Skins
 @@ -56,7 +58,9 @@ cd ..  cd Plugins
  del /Q %name%W.dll
 +del /Q %name%W.pdb
  copy "..\..\..\..\bin\release\Plugins\%name%.dll"
 +copy ..\..\Release\%name%.pdb
  cd ..
  "C:\Program Files\Filzip\Filzip.exe" -a -rp %name%.zip Plugins Docs Skins
 | 
