Beispiel #1
0
QSP_BOOL qspStatementAddObject(QSPVariant *args, int count, QSP_CHAR **jumpTo, int extArg)
{
	QSPObj *obj;
	int i, objInd;
	QSP_CHAR *imgPath;
	if (count == 3)
	{
		objInd = QSP_NUM(args[2]) - 1;
		if (objInd < 0 || objInd > qspCurObjectsCount) return QSP_FALSE;
	}
	else
		objInd = qspCurObjectsCount;
	if (qspCurObjectsCount == QSP_MAXOBJECTS)
	{
		qspSetError(QSP_ERR_CANTADDOBJECT);
		return QSP_FALSE;
	}
	if (qspCurSelObject >= objInd) qspCurSelObject = -1;
	if (count >= 2 && qspIsAnyString(QSP_STR(args[1])))
		imgPath = qspGetAbsFromRelPath(QSP_STR(args[1]));
	else
		imgPath = 0;
	for (i = qspCurObjectsCount; i > objInd; --i)
		qspCurObjects[i] = qspCurObjects[i - 1];
	++qspCurObjectsCount;
	obj = qspCurObjects + objInd;
	obj->Image = imgPath;
	obj->Desc = qspGetNewText(QSP_STR(args[0]), -1);
	qspIsObjectsChanged = QSP_TRUE;
	qspExecLocByVarNameWithArgs(QSP_FMT("ONOBJADD"), args, (count < 3 ? count : 2));
	return QSP_FALSE;
}
void qspAddAction(QSPVariant *args, int count, QSPLineOfCode *code, int start, int end, QSP_BOOL isManageLines)
{
	QSPCurAct *act;
	QSP_CHAR *imgPath;
	if (qspActIndex(QSP_STR(args[0])) >= 0) return;
	if (qspCurActionsCount == QSP_MAXACTIONS)
	{
		qspSetError(QSP_ERR_CANTADDACTION);
		return;
	}
	if (count == 2 && qspIsAnyString(QSP_STR(args[1])))
		imgPath = qspGetAbsFromRelPath(QSP_STR(args[1]));
	else
		imgPath = 0;
	act = qspCurActions + qspCurActionsCount++;
	act->Image = imgPath;
	act->Desc = qspGetNewText(QSP_STR(args[0]), -1);
	qspCopyPrepLines(&act->OnPressLines, code, start, end);
	act->OnPressLinesCount = end - start;
	act->Location = qspRealCurLoc;
	act->ActIndex = qspRealActIndex;
	act->StartLine = qspRealLine;
	act->IsManageLines = isManageLines;
	qspIsActionsChanged = QSP_TRUE;
}
Beispiel #3
0
static void qspPlayFile(QSP_CHAR *s, int volume, QSP_BOOL isAddToPlayList)
{
	int len;
	QSP_CHAR buf[4], *file;
	if (!qspIsAnyString(s)) return;
	if (volume < 0)
		volume = 0;
	else if (volume > 100)
		volume = 100;
	file = qspGetAbsFromRelPath(s);
	qspCallPlayFile(file, volume);
	free(file);
	if (isAddToPlayList)
	{
		if (qspPLFilesCount == QSP_MAXPLFILES)
		{
			qspRefreshPlayList();
			if (qspPLFilesCount == QSP_MAXPLFILES) return;
		}
		len = qspAddText(&file, s, 0, -1, QSP_TRUE);
		if (volume != 100)
		{
			len = qspAddText(&file, QSP_PLVOLUMEDELIM, len, 1, QSP_FALSE);
			file = qspGetAddText(file, qspNumToStr(buf, volume), len, -1);
		}
		qspPLFiles[qspPLFilesCount++] = file;
	}
}
Beispiel #4
0
void qspRefreshPlayList()
{
	QSP_CHAR **s, *file, *str, *pos;
	int count = qspPLFilesCount;
	if (!count) return;
	qspCopyStrs(&s, qspPLFiles, 0, count);
	qspClearPlayList(QSP_FALSE);
	while (--count >= 0)
	{
		str = s[count];
		pos = qspStrChar(str, QSP_PLVOLUMEDELIM[0]);
		if (pos) *pos = 0;
		if (qspIsAnyString(str))
		{
			file = qspGetAbsFromRelPath(str);
			if (qspSearchPlayList(str) < 0 && qspCallIsPlayingFile(file))
			{
				if (pos) *pos = QSP_PLVOLUMEDELIM[0];
				qspPLFiles[qspPLFilesCount++] = qspGetNewText(str, -1);
			}
			free(file);
		}
		free(str);
	}
	free(s);
}
Beispiel #5
0
QSP_BOOL qspStatementShowMenu(QSPVariant *args, int count, QSP_CHAR **jumpTo, int extArg)
{
	int ind, maxItems, len;
	QSPVar *var;
	QSP_CHAR *imgPath, *str, *pos, *pos2;
	if (!(var = qspVarReferenceWithType(QSP_STR(args[0]), QSP_FALSE, 0))) return QSP_FALSE;
	qspClearMenu(QSP_FALSE);
	qspCallDeleteMenu();
	if (count == 1)
	{
		ind = 0;
		maxItems = QSP_MAXMENUITEMS;
	}
	else
	{
		ind = QSP_NUM(args[1]);
		if (ind < 0) ind = 0;
		if (count == 2)
			maxItems = QSP_MAXMENUITEMS;
		else
		{
			maxItems = QSP_NUM(args[2]);
			if (maxItems < 0) maxItems = 0;
		}
	}
	while (ind < var->ValsCount)
	{
		if (qspCurMenuItems == maxItems) break;
		if (!((str = var->Values[ind].Str) && qspIsAnyString(str))) break;
		if (!(pos2 = qspInStrRChars(str, QSP_MENUDELIM, 0)))
		{
			qspSetError(QSP_ERR_COLONNOTFOUND);
			return QSP_FALSE;
		}
		if (qspCurMenuItems == QSP_MAXMENUITEMS)
		{
			qspSetError(QSP_ERR_CANTADDMENUITEM);
			return QSP_FALSE;
		}
		if (pos = qspInStrRChars(str, QSP_MENUDELIM, pos2))
		{
			len = (int)(pos2 - pos) - 1;
			imgPath = (qspIsAnyString(++pos2) ? qspGetAbsFromRelPath(pos2) : 0);
		}
		else
		{
			pos = pos2;
			len = -1;
			imgPath = 0;
		}
		qspCurMenuLocs[qspCurMenuItems++] = qspGetNewText(pos + 1, len);
		*pos = 0;
		qspCallAddMenuItem(str, imgPath);
		*pos = QSP_MENUDELIM[0];
		if (imgPath) free(imgPath);
		++ind;
	}
	if (qspCurMenuItems) qspCallShowMenu();
	return QSP_FALSE;
}
Beispiel #6
0
QSP_BOOL qspStatementCloseFile(QSPVariant *args, int count, QSP_CHAR **jumpTo, int extArg)
{
	int pos;
	QSP_CHAR *file;
	if (!qspPLFilesCount) return QSP_FALSE;
	if (count)
	{
		if (qspIsAnyString(QSP_STR(args[0])))
		{
			pos = qspSearchPlayList(QSP_STR(args[0]));
			if (pos >= 0)
			{
				file = qspGetAbsFromRelPath(QSP_STR(args[0]));
				qspCallCloseFile(file);
				free(file);
				do
				{
					free(qspPLFiles[pos]);
					--qspPLFilesCount;
					while (pos < qspPLFilesCount)
					{
						qspPLFiles[pos] = qspPLFiles[pos + 1];
						++pos;
					}
					pos = qspSearchPlayList(QSP_STR(args[0]));
				} while (pos >= 0);
			}
		}
	}
	else
	{
		qspClearPlayList(QSP_FALSE);
		qspCallCloseFile(0);
	}
	return QSP_FALSE;
}