Exemplo n.º 1
0
extern "C" void x_updatepath (lua_State* L) {
	LPRDATA rdPtr = XLuaGlobal::Get().GetStateByState(L)->rdList.front()->rdPtr;

	char* drive = (char*) calloc(_MAX_PATH, sizeof(char));
	char* dir = (char*) calloc(_MAX_PATH, sizeof(char));
	callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_DRIVE, (long)drive);
	callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_DIR, (long)dir);
	//rdPtr->rRd->GetApplicationDrive(drive);
	//rdPtr->rRd->GetApplicationDirectory(dir);

	std::stringstream pstr; pstr << drive << dir << "?.lua;";
	std::stringstream cstr; cstr << drive << dir << "?.dll;";

	free(drive);
	free(dir);

	lua_getfield(L, -1, "path");
	pstr << lua_tostring(L, -1);

	lua_pop(L, 1);
	lua_pushstring(L, pstr.str().c_str());
	lua_setfield(L, -2, "path");

	lua_getfield(L, -1, "cpath");
	cstr << lua_tostring(L, -1);

	lua_pop(L, 1);
	lua_pushstring(L, cstr.str().c_str());
	lua_setfield(L, -2, "cpath");
	
	//lua_settop(L, top);
}
Exemplo n.º 2
0
// ---------------------
// SetRunObjectTextColor
// ---------------------
// Change the text color of the object.
// 
void WINAPI SetRunObjectTextColor(LPRDATA rdPtr, COLORREF rgb)
{
	rdPtr->textColor = rgb;

	// Redraw object
	callRunTimeFunction(rdPtr, RFUNCTION_REDRAW, 0, 0);
}
Exemplo n.º 3
0
void XLuaObject::RaisePrint (const std::string& str) {
	if (printQueue.size() >= 2000) {
		printQueue.pop();
	}
	printQueue.push(str);
	lastPrintString = str;

	if (rdPtr == NULL) return;

	if (printMode == 0) {
		callRunTimeFunction(rdPtr, RFUNCTION_GENERATEEVENT, 2, 0);
		//rdPtr->rRd->GenerateEvent(2);
	}
	else if (printMode == 1) {
		callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENT, 2, 0);
		//rdPtr->rRd->PushEvent(2);
	}
}
Exemplo n.º 4
0
// ---------------
// CreateRunObject
// ---------------
// The routine where the object is actually created
// 
short WINAPI DLLExport CreateRunObject(LPRDATA rdPtr, LPEDATA edPtr, fpcob cobPtr)
{
/*
   This routine runs when your object is created, as you might have guessed.
   It is here that you must transfer any data you need in rdPtr from edPtr,
   because after this has finished you cannot access it again!
   Also, if you have anything to initialise (e.g. dynamic arrays, surface objects)
   you should do it here, and free your resources in DestroyRunObject.
*/
	LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;

	rdPtr->rHo.hoX = cobPtr->cobX;
	rdPtr->rHo.hoY = cobPtr->cobY;
	rdPtr->rHo.hoImgWidth = edPtr->nWidth;
	rdPtr->rHo.hoImgHeight = edPtr->nHeight;

	// Initialize RUNDATA members
	rdPtr->textColor = edPtr->textColor;
	rdPtr->backColor = edPtr->backColor;
	rdPtr->dwAlignFlags = edPtr->dwAlignFlags;
	rdPtr->dwFlags = edPtr->dwFlags;
	rdPtr->hFont = CreateFontIndirect(&edPtr->textFont);
	rdPtr->dwLastChangedLoopNumber = -1;
	rdPtr->dwEvtFlags = 0;

	// Create control window
	DWORD dwStyle = WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_VISIBLE;
	if ((edPtr->dwFlags & SCTRL_BORDER) != 0)
		dwStyle |= WS_BORDER;
	rdPtr->hWnd = CreateWindowEx(0, _T("EDIT"), NULL, dwStyle, 
									rdPtr->rHo.hoX - rhPtr->rhWindowX, rdPtr->rHo.hoY - rhPtr->rhWindowY, 
									rdPtr->rHo.hoImgWidth, rdPtr->rHo.hoImgHeight, 
									rhPtr->rhHEditWin, NULL, rhPtr->rh4.rh4Instance, NULL);

	// Set text & font
	if ( rdPtr->hWnd != NULL )
	{
		// Let MMF subclass window
		rdPtr->nWnds = 1;
		rdPtr->rHo.hoOffsetToWindows = (short)((LPBYTE)&rdPtr->nWnds - (LPBYTE)rdPtr);
		callRunTimeFunction(rdPtr, RFUNCTION_SUBCLASSWINDOW, 0, 0);

		// Create background brush
		rdPtr->hBrush = NULL;
		if ( (rdPtr->dwFlags & SCTRL_SYSTEMCOLORS) == 0 )
			rdPtr->hBrush = CreateSolidBrush(rdPtr->backColor);

		// Set font
		SendMessage(rdPtr->hWnd, WM_SETFONT, (WPARAM)rdPtr->hFont, MAKELONG(TRUE, 0));

		// Set Text
		SetWindowText(rdPtr->hWnd, edPtr->sText);
	}

	// No errors
	return 0;
}
Exemplo n.º 5
0
void XLuaObject::RaiseError (const std::string& str) {
	if (errorQueue.size() >= 20) {
		errorQueue.pop();
	}

	errorQueue.push(str);
	lastErrorString = str;

	if (rdPtr == NULL) return;

	if (errMode == 0) {
		callRunTimeFunction(rdPtr, RFUNCTION_GENERATEEVENT, 0, 0);
		//rdPtr->rRd->GenerateEvent(0);
	}
	else if (errMode == 1) {
		callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENT, 0, 0);
		//rdPtr->rRd->PushEvent(0);
	}
}
Exemplo n.º 6
0
// ----------------
// HandleRunObject
// ----------------
// Called (if you want) each loop, this routine makes the object live
// 
short WINAPI DLLExport HandleRunObject(LPRDATA rdPtr)
{
	// If text has been modified, generate a CND_CHANGED condition
	if ( (rdPtr->dwEvtFlags & EVTFLAG_CHANGED) != 0 )
	{
		callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENTSTOP, CND_CHANGED, 0);
		rdPtr->dwEvtFlags &= ~EVTFLAG_CHANGED;
	}
	return 0;
}
Exemplo n.º 7
0
// -------------------
// SetRunObjectFont
// -------------------
// Change the font used by the object.
// 
void WINAPI SetRunObjectFont(LPRDATA rdPtr, LOGFONT* pLf, RECT* pRc)
{
	HFONT hFont = CreateFontIndirect(pLf);
	if ( hFont != NULL )
	{
		// Change font
		if (rdPtr->hFont!=0)
			DeleteObject(rdPtr->hFont);
		rdPtr->hFont = hFont;

		// Redraw object
		callRunTimeFunction(rdPtr, RFUNCTION_REDRAW, 0, 0);
	}

}
Exemplo n.º 8
0
// GenerateEvent:  *instantly* generates an event
_inline void GenerateEvent(LPRDATA rdPtr, int EventID)
{	callRunTimeFunction(rdPtr,RFUNCTION_GENERATEEVENT,EventID,0); }
Exemplo n.º 9
0
// ----------------
// HandleRunObject
// ----------------
// Called (if you want) each loop, this routine makes the object live
// 
short WINAPI DLLExport HandleRunObject(LPRDATA rdPtr)
{
	int fixedvalue = 0;
	bool finnishedMoving = false;
	float step;

	for(unsigned int i = 0; i<rdPtr->controlled.size(); i++)
	{
		fixedvalue = 0;
		LPRO object = NULL;
		MoveStruct & moved = rdPtr->controlled.at(i);

		if(i >= 0 && i < rdPtr->controlled.size())
		{
			fixedvalue = moved.fixedValue;
			object = LproFromFixed(rdPtr,fixedvalue);
		}

		if( object != NULL )
		{
			if(moved.timeMode == 0)
			{
				__int64 currentTime = CurrentTime();
				__int64 diff = currentTime - moved.starttime;

				step = diff / (float)moved.timespan;

				if(diff >= moved.timespan)
					finnishedMoving = true;
			}
			else
			{
				moved.eventloop_step++;
				step = moved.eventloop_step / (float)moved.timespan;

				if(moved.eventloop_step >= moved.timespan)
					finnishedMoving = true;
			}

			float easeStep = (float)calculateEasingValue(moved.easingMode,moved.functionA,moved.functionB,step, moved.vars);
			
			object->roHo.hoX = (int)(moved.startX + (moved.destX-moved.startX)*easeStep + 0.5f);
			object->roHo.hoY = (int)(moved.startY + (moved.destY-moved.startY)*easeStep + 0.5f);
			object->roc.rcChanged = true;

			if(finnishedMoving)
			{
				finnishedMoving = false;

				object->roHo.hoX = moved.destX;
				object->roHo.hoY = moved.destY;
				
				rdPtr->deleted.push_back(moved);

				rdPtr->controlled.erase( rdPtr->controlled.begin() + i );
				i--;
			}
		}
		else
		{
			rdPtr->controlled.erase( rdPtr->controlled.begin() + i );
			i--;
		}
	}

	//Trigger the 'Object stopped moving' events
	for(unsigned int d=0; d<rdPtr->deleted.size(); ++d)
	{
		rdPtr->currentMoved = rdPtr->deleted.at(d);
		callRunTimeFunction(rdPtr,RFUNCTION_GENERATEEVENT,CND_SPECIFICOBJECTSTOPPED,0);
		callRunTimeFunction(rdPtr,RFUNCTION_GENERATEEVENT,CND_ANYOBJECTSTOPPED,0);
	}
	
	rdPtr->deleted.clear();

	return 0;
}
Exemplo n.º 10
0
// ----------------
// HandleRunObject
// ----------------
// Called (if you want) each loop, this routine makes the object live
// 
short WINAPI DLLExport HandleRunObject(LPRDATA rdPtr)
{
	////////////////////////////
	//Main function timer loop//
	////////////////////////////

	for( int i=0; i<rdPtr->FunctionList.Size();i++ )
	{
		rdPtr->CurrentFuncIndex = i;
		FuncStruct * CurrentStruct = rdPtr->FunctionList.GetItem(i);
	
		if( !CurrentStruct )
			return 0;

		/////////////////////////////////////////////////////////////////////////////////////////////////////////
		//Delete the function if it was marked as successfull or if function is immediate but not asked to loop//
		/////////////////////////////////////////////////////////////////////////////////////////////////////////
		if( CurrentStruct->DeleteMe == true || (CurrentStruct->ImmediateFunc && !CurrentStruct->ImmediateApproved) )
		{
			delete [] CurrentStruct->FuncName;
			rdPtr->FunctionList.Delete(i);
			i = max( i-1, 0);
			continue;
		}

		/////////////////////////////////////////////////////////////////////////////////
		//When the time expires, trigger the functions if function is not set to repeat//
		/////////////////////////////////////////////////////////////////////////////////
		if( CurrentStruct->Time <= 0)
		{
			bool DeleteMe = true;

			// Update the 'Last function name' in the rdPtr structure
				delete [] rdPtr->LastFuncName;
				int strl = strlen(CurrentStruct->FuncName)+1;
				rdPtr->LastFuncName = new char[strl];
				strcpy_s( rdPtr->LastFuncName, strl, CurrentStruct->FuncName);
				
			//Handle repeatable functions.
				if( CurrentStruct->Repeat > 1 || CurrentStruct->Repeat == -1 )
				{
					CurrentStruct->Time = CurrentStruct->InitialTime;
					CurrentStruct->Repeat = max(CurrentStruct->Repeat-1,-1);
					DeleteMe = false;
				}

			//Trigger the 'On function' events
				callRunTimeFunction(rdPtr,RFUNCTION_GENERATEEVENT,0,0);
				callRunTimeFunction(rdPtr,RFUNCTION_GENERATEEVENT,1,0);

			
			//Delete the function from the queue
				if(DeleteMe && CurrentStruct->WaitForSuccellfull == false)
				{
					delete [] CurrentStruct->FuncName;
					rdPtr->FunctionList.Delete(i);
					i = max( i-1, 0);
					continue;
				}
		}
		else CurrentStruct->Time--;
	}


	return 0;
}
Exemplo n.º 11
0
// GetStringSpaceOld:  gets some string space for an expression to return a string with.
// returns a pointer to your new memory.  MMF will automatically free this memory soon after your expression routine finishes
// LIMITED TO 32KB - but compatible with all builds
_inline char* GetStringSpaceOld(LPRDATA rdPtr, int size)
{	return (char *)callRunTimeFunction(rdPtr,RFUNCTION_GETSTRINGSPACE,size,0); }
Exemplo n.º 12
0
// ReHandleObject:  start calling HandleRunObject() again
_inline void ReHandleObject(LPRDATA rdPtr)
{	callRunTimeFunction(rdPtr,RFUNCTION_REHANDLE,0,0);	}
Exemplo n.º 13
0
// DestroyObject:  destroys your object like the Destroy action (will call DestroyRunObject etc. etc.)
_inline void DestroyObject(LPRDATA rdPtr)
{	callRunTimeFunction(rdPtr,RFUNCTION_DESTROY,0,0);	}
Exemplo n.º 14
0
// PushEvent:  same as GenerateEvent, but the event is only generated at the end of MMF's event loop
_inline void PushEvent(LPRDATA rdPtr, int EventID)
{	callRunTimeFunction(rdPtr,RFUNCTION_PUSHEVENT,EventID,0); }
Exemplo n.º 15
0
void JNICALL JVM::MMF2_Funcs_Position(JNIEnv *env, jobject obj, jint x, jint y)
{
	callRunTimeFunction(GrabPtr<RD>(env, obj), RFUNCTION_SETPOSITION, x, y);
}
Exemplo n.º 16
0
void JNICALL JVM::MMF2_Funcs_Redraw(JNIEnv *env, jobject obj)
{
	callRunTimeFunction(GrabPtr<RD>(env, obj), RFUNCTION_REDRAW, 0, 0);
}
Exemplo n.º 17
0
void JNICALL JVM::MMF2_Funcs_Rehandle(JNIEnv *env, jobject obj)
{
	callRunTimeFunction(GrabPtr<RD>(env, obj), RFUNCTION_REHANDLE, 0, 0);
}
Exemplo n.º 18
0
void JNICALL JVM::MMF2_Funcs_TriggerCondition(JNIEnv *env, jobject obj, jobject RunExt, jint ID)
{
	callRunTimeFunction(GrabPtr<RD>(env, obj), RFUNCTION_GENERATEEVENT, ID, 0);
}