Example #1
0
void TopWindow::DefaultBreak()
{
	if(FindAction(IDCANCEL) || close_rejects)
		RejectBreak(IDCANCEL);
	else
	if(FindAction(IDNO))
		RejectBreak(IDNO);
	else
	if(FindAction(IDEXIT))
		AcceptBreak(IDEXIT);
	else
	if(FindAction(IDYES))
		AcceptBreak(IDYES);
	else
		AcceptBreak(IDOK);
}
	void SpriteRenderer::Init(RenderDevice * device)
	{
		mInited = true;
		if (device == nullptr)
			return;

		Image * image = FindAction("image")->As<Image>();
		assert(image != nullptr);

		image->Init(device);
		image->GetImageInfo(&mTexture, &mSize);

		assert(mTexture != nullptr);

		// TODO: Handle failed case -- do not throw exception because I'm not using these! -Will
		mPosition = Search("position");
		mRotation = Search("rotation");
		mScale = Search("scale");

		mShader = device->CreateShader("Content/shader/glsl/sprite_v.glsl", "Content/shader/glsl/sprite_f.glsl", "");


		mBuffer = device->CreateBuffer(false);
		SetBufferData();
	}
Example #3
0
void G_UnregisterAction(char *name)
{
    action_t    *action;
    action_t    *tree;
    char        buff[256];
    
    dstrcpy(buff, name);
    dstrlwr(buff);

    action = FindAction(buff);

    if(!action)
        return;

    if(!action->children[0])
    {
        ReplaceActionWith(action, action->children[1]);
    }
    else if(!action->children[1])
    {
        ReplaceActionWith(action, action->children[0]);
    }
    else
    {
        tree = action->children[1];
        while(tree->children[0])
            tree = tree->children[0];

        tree->children[0] = action->children[0];

        action->children[0]->parent = tree;
        G_OptimizeActionTree();
    }
    G_FreeAction(action);
}
Example #4
0
TopWindow::Abreak *TopWindow::FindAddAction(int ID)
{
	Abreak *x = FindAction(ID);
	if(x) return x;
	Abreak& a = action.Add();
	a.ID = ID;
	a.dlg = this;
	return &a;
}
	void SpriteRenderer::SetUV(float origin_x, float origin_y, float width, float height)
	{
		(origin_x); (origin_y); (width); (height);
		Image * image = FindAction("image")->As<Image>();
		assert(image != nullptr);

		glm::vec4 size = (*image)["size"].Get<glm::vec4>();

		mU = origin_x / size.x;
		mV = 1.0f - (origin_y + height) / size.y;
		mUWidth = width / size.x;
		mVHeight = height / size.y;

		SetBufferData();
	}
Example #6
0
void TryActions(alist_t *al, dboolean up)
{
    if(!al)
        return;
    
    if(up)
    {
        action_t    *action;
        char        buff[256];
        
        if(al->next || (al->cmd[0] != '+'))
            return;
        
        dstrcpy(buff, al->cmd);
        buff[0] = '-';
        action = FindAction(buff);
        if(action)
            action->proc(action->data, al->param);
        return;
    }

    AddActions(DoRunActions(al, false));
}
Example #7
0
const test6::dActionEntry* test6::GetNextAction (dList<dStackPair>& stack, dToken token, xxxx& scanner) const
{
	static short actionsCount[] = {
			2, 1, 1, 1, 1};
	static short actionsStart[] = {
			0, 2, 3, 4, 5};
	static dActionEntry actionTable[] = {
			dActionEntry (254, 0, 1, 0, 0, 1), dActionEntry (256, 0, 1, 1, 0, 3), dActionEntry (256, 0, 1, 2, 0, 4), dActionEntry (254, 0, 2, 0, 0, 0), 
			dActionEntry (256, 0, 0, 4, 0, 0), dActionEntry (254, 0, 1, 0, 3, 2)};

	bool errorMode = false;
	const dStackPair& stackTop = stack.GetLast()->GetInfo();
	int state = stackTop.m_state;
	int start = actionsStart[state];
	int count = actionsCount[state];

	const dActionEntry* const table = &actionTable[start];
	const dActionEntry* action = FindAction (table, count, token);
	while (!action && (stack.GetCount() > 1)) {
		errorMode = true; 

		// we found a syntax error in go into error recovering mode, and find the token mark by a ". error" rule
		stack.Remove (stack.GetLast());

		const dStackPair& stackTop = stack.GetLast()->GetInfo();
		int state = stackTop.m_state;
		int start = actionsStart[state];
		int count = actionsCount[state];
		const dActionEntry* const table = &actionTable[start];
		action = FindAction (table, count, ERROR_TOKEN);
		if (action && !action->m_errorRule) {
			action = NULL;
		}
	}

	if (errorMode && action) {
		dStackPair& stackTop = stack.GetLast()->GetInfo();
		stackTop.m_token = ERROR_TOKEN;

		int state = action->m_nextState;
		int start = actionsStart[state];
		int count = actionsCount[state];
		const dActionEntry* const table = &actionTable[start];

		// find the next viable token to continues parsing
		while (!FindAction (table, count, token)) {
			token = dToken (scanner.NextToken());
			if (token == -1) {
				// reached end of the file, can not recover from this error;
				return NULL;
			}
		}
		action = FindAction (table, count, token);
		
		dStackPair& entry = stack.Append()->GetInfo();
		entry.m_state = state;
		entry.m_scannerLine = stackTop.m_scannerLine;
		entry.m_scannerIndex = stackTop.m_scannerIndex;
		entry.m_value = dUserVariable (ERROR_TOKEN, "error", entry.m_scannerLine, entry.m_scannerIndex);
		entry.m_token = token;
	}

	return action;
}
Example #8
0
bool test4::Parce(lextest1& scanner)
{
	dList<dStackPair> stack;
	static short actionsCount[] = {2, 1, 2, 1, 1, 2, 2, 2, 1, 2};
	static short actionsStart[] = {0, 2, 0, 3, 4, 5, 7, 0, 9, 5};
	static dActionEntry actionTable[] = {
					dActionEntry (259, 0, 1, 0, 0), dActionEntry (256, 0, 2, 0, 0), 
					dActionEntry (0, 1, 0, 1, 3), 
					dActionEntry (0, 2, 0, 0, 0), 
					dActionEntry (257, 0, 5, 0, 0), 
					dActionEntry (259, 0, 6, 0, 0), dActionEntry (256, 0, 7, 0, 0), 
					dActionEntry (0, 1, 0, 1, 3), dActionEntry (258, 1, 0, 1, 3), 
					dActionEntry (257, 0, 9, 0, 0), 
			};

	static short gotoCount[] = {1, 0, 1, 0, 0, 1, 0, 1, 0, 1};
	static short gotoStart[] = {0, 1, 1, 2, 2, 2, 3, 3, 4, 4};
	static dGotoEntry gotoTable[] = {
					dGotoEntry (261, 3), dGotoEntry (261, 4), dGotoEntry (261, 4), dGotoEntry (261, 8), 
					dGotoEntry (261, 8)};

	const int lastToken = 261;

	stack.Append ();
	dToken token = dToken (scanner.NextToken());
	for (;;) {
		const dStackPair& stackTop = stack.GetLast()->GetInfo();
		int start = actionsStart[stackTop.m_state];
		int count = actionsCount[stackTop.m_state];
		const dActionEntry* const action (FindAction (&actionTable[start], count, token));
		_ASSERTE (action);

		switch (action->m_stateType) 
		{
			case dSHIFT: 
			{
				dStackPair& entry = stack.Append()->GetInfo();
				entry.m_token = dToken (action->m_token);
				entry.m_state = action->m_nextState;
				entry.m_value = dStackPair::dUserVariable (entry.m_token, scanner.GetTokenString());
				token = dToken (scanner.NextToken());
				if (token == -1) {
					token = dToken (0);
				}

				break;
			}

			case dREDUCE: 
			{
				dStackPair parameter[MAX_USER_PARAM];

				int reduceCount = action->m_ruleSymbols;
				_ASSERTE (reduceCount < sizeof (parameter) / sizeof (parameter[0]));

				for (int i = 0; i < reduceCount; i ++) {
					parameter[reduceCount - i - 1] = stack.GetLast()->GetInfo();
					stack.Remove (stack.GetLast());
				}

				const dStackPair& stackTop = stack.GetLast()->GetInfo();
				int start = gotoStart[stackTop.m_state];
				int count = gotoCount[stackTop.m_state];
				const dGotoEntry* const gotoEntry = FindGoto (&gotoTable[start], count, dToken (action->m_nextState + lastToken));

				dStackPair& entry = stack.Append()->GetInfo();
				entry.m_state = gotoEntry->m_nextState;
				entry.m_token = dToken (gotoEntry->m_token);
				
				switch (action->m_ruleIndex) 
				{
					//do user semantic Actions
					case 3:// rule stmt : a 
						{}
						break;

					default:;
				}

				break;

			}
	
			case dACCEPT: // 2 = accept
			{
				// program parced successfully, exit with successful code
				return true;
			}
			
			default:  
			{
				_ASSERTE (0);
				// syntact error parciing program
				//if (!ErrorHandler ("error")) {
				//}
				break;
			}
		}
	}
	return false;
}
Example #9
0
int test0::Parce(lextest1& scanner)
{
	dList<dStackPair> stack;
	static int actionsCount[] = {2, 2, 5, 2, 5, 2, 2, 5, 5};
	static int actionsStart[] = {0, 2, 4, 9, 11, 16, 18, 20, 25};
	static int actionTable[] = {0xc0a0, 0x10400, 0x2, 0x140ac, 0x4000001, 0x40000a1, 0x40000a5, 0x40000ad, 0x4000401, 0xc0a0, 0x10400, 0x4004001, 0x40040a1, 0x40040a5, 0x40040ad, 0x4004401, 0xc0a0, 0x10400, 0x1c0a4, 0x140ac, 0xc004001, 0xc0040a1, 0xc0040a5, 0xc0040ad, 0xc004401, 0xc000001, 0xc0000a1, 0xc0000a5, 0xc0000ad, 0xc000401};

	static int gotoCount[] = {2, 0, 0, 2, 0, 1, 0, 0, 0};
	static int gotoStart[] = {0, 2, 2, 2, 4, 4, 5, 5, 5};
	static int gotoTable[] = {0x10101, 0x20102, 0x60101, 0x20102, 0x80102};

	const int lastToken = 257;

	stack.Append ();
	for (dToken token = dToken (scanner.NextToken()); token != -1; ) {
		const dStackPair& stackTop = stack.GetLast()->GetInfo();
		int start = actionsStart[stackTop.m_state];
		int count = actionsCount[stackTop.m_state];
		dActionEntry action (FindAction (&actionTable[start], count, token));

		switch (action.m_stateType) 
		{
			case 0: // 0 = shift
			{
				dStackPair& entry = stack.Append()->GetInfo();
				entry.m_token = dToken (action.m_token);
				entry.m_state = action.m_nextState;
				entry.m_value = dStackPair::dUserVariable (entry.m_token, scanner.GetTokenString());
				token = dToken (scanner.NextToken());
				break;
			}

			case 1: // 1 = reduce
			{
				dStackPair parameter[MAX_USER_PARAM];

				int reduceCount = action.m_reduceCount;
				_ASSERTE (reduceCount < sizeof (parameter) / sizeof (parameter[0]));

				for (int i = 0; i < reduceCount; i ++) {
					parameter[i] = stack.GetLast()->GetInfo();
					stack.Remove (stack.GetLast());
				}

				const dStackPair& stackTop = stack.GetLast()->GetInfo();
				int start = gotoStart[stackTop.m_state];
				int count = gotoCount[stackTop.m_state];
				dGotoEntry gotoEntry (FindGoto (&gotoTable[start], count, dToken (action.m_nextState + lastToken)));

				dStackPair& entry = stack.Append()->GetInfo();
				entry.m_state = gotoEntry.m_nextState;
				entry.m_token = dToken (gotoEntry.m_token);
				
				switch (action.m_nextState) 
				{
					//do user semantic Action
					//$(semanticActionsCode);
					case 0:
					{
						break;
					}
					default:;
				}

				break;

			}
	
			case 2: // 2 = accept
			{
				_ASSERTE (0);
			}
			
			default:  // syntax grammar error
			{
				_ASSERTE (0);
				// error
				//if (!ErrorHandler ("error")) {
				//}
			}
		}
	}

	return 1;
}
Example #10
0
alist_t *DoRunActions(alist_t *al, dboolean free)
{
    alist_t     *next = NULL;
    action_t    *action;
    cvar_t      *cvar;
    
    while(al)
    {
        next = al->next;
        if(dstrcmp(al->cmd, "wait") == 0)
            break;
        
        action = FindAction(al->cmd);
        if(action)
        {
            action->proc(action->data, al->param);
        }
        else if(cvar = CON_CvarGet(al->cmd))
        {
            if(netgame)
            {
                if(cvar->nonclient)
                {
                    // I'll just have to assume for now that
                    // player# 0 is the server..
                    if(consoleplayer != 0)
                    {
                        CON_Warnf("Cannot change cvar that's locked by server\n");
                        goto next;
                    }
                }
            }

            if(!al->param[0])
            {
                char str[256];
                sprintf(str, "%s: %s (%s)", cvar->name, cvar->string, cvar->defvalue);
                CON_AddLine(str, dstrlen(str));
            }
            else
            {
                CON_CvarSet(cvar->name, al->param[0]);
                if(netgame)
                {
                    if(playeringame[0] && consoleplayer == 0)
                        NET_SV_UpdateCvars(cvar);
                }
            }
        }
        else
            CON_Warnf("Unknown command \"%s\"\n", al->cmd);
        
next:
        if(free)
            DerefSingleAction(al);
        
        al = next;
    }
    
    if(al) // reached wait command
    {
        if(free)
            DerefSingleAction(al);
        
        if(next != NULL)
            return next;
    }

    return al;
}