Ejemplo n.º 1
0
int
CKLBFormIF::updateNode(CLuaState& lua, int argc, int base, CKLBNode * pParent, int nodeIndex, int subcmd, void * item, int index)
{
	CKLBNode * pNode = NULL;
	if(lua.isString(nodeIndex)) {
		const char * name = lua.getString(nodeIndex);
		if (name) {
			pNode = pParent->search(name);
		}
		klb_assert(pNode, "Node not found: name = \"%s\"", name);
	} else {
		pNode = (CKLBNode *)lua.getPointer(nodeIndex);
	}
	int ret = 0;

	if(base > argc) {
		lua.retBoolean(false);
		return 1;
	}

	if (!pNode) {
		lua.retNil();
		return 1;
	}

	CKLBUITask* pTask		= pNode->getUITask();
	u32 classID;
	if (pTask) {
		classID = pTask->getClassID();
	} else {
		classID = pNode->getClassID();
	}

	// 対象のノードによって、可能な操作が異なる。
	bool result;
	switch(classID)
	{
	default:					result = updateStandardNode(lua, argc, base, subcmd, pNode, ret, item, index);	break;
	case CLS_KLBUIELEMENT:		result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);		break;
	case CLS_KLBUISELECTABLE:	result = updateUISelectable(lua, argc, base, subcmd, pNode, ret, item, index);	break;
	case CLS_KLBUICONTAINER:	result = updateUIContainer(lua, argc, base, subcmd, pNode, ret, item, index);	break;
	case CLS_KLBUILABEL:
	case CLS_KLBLABEL:			result = updateLabelNode(lua, argc, base, subcmd, pNode, ret, item, index);		break;
	case CLS_KLBTEXTEDIT:
	case CLS_KLBUITEXTINPUT:	result = updateUITextEdit(lua, argc, base, subcmd, pNode, ret, item, index);	break;
	case CLS_KLBUIWEBVIEW:
	case CLS_KLBWEBVIEW:		result = updateUIWebView(lua, argc, base, subcmd, pNode, ret, item, index);	break;
	}
	// ここまでで処理されたコマンドが無い場合、標準コマンドを処理する。
	if(!result) {
		// コマンドとして解釈できなかったので、falseを返す。
		lua.retBoolean(false);
		ret = 1;
	}
	// 戻り値に相当するものはすでにLuaスタックに積んであるはずなので、戻り値の数を返す。
	return ret;
}
Ejemplo n.º 2
0
	// ***************************************************************************
	int CInterfaceElement::luaSetPosRef(CLuaState &ls)
	{
		CLuaIHM::checkArgCount(ls, "setPosRef", 1);
		CLuaIHM::check(ls,   ls.isString(1),    "setPosRef() requires a string in param 1");

		// get hotspot
		THotSpot	newParentPosRef, newPosRef;
		convertHotSpotCouple(ls.toString(1), newParentPosRef, newPosRef);

		// if different from current, set,a nd invalidate coords
		if(newParentPosRef!=getParentPosRef() || newPosRef!=getPosRef())
		{
			setParentPosRef(newParentPosRef);
			setPosRef(newPosRef);
			invalidateCoords();
		}

		return 0;
	}
Ejemplo n.º 3
0
bool
CKLBFormIF::updateUISelectable(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBUISelectable * pSelectable = (CKLBUISelectable *)pNode;
	bool result = true;
	switch(subcmd)
	{
	default:
		{
			// selectable専用コマンドに該当しなければ Element として処理する
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_UIS_SET_CLICK:
		{
			if(argc != 8) {
				result = false;
				break;
			}
			s32 x = lua.getInt(base + 1);
			s32 y = lua.getInt(base + 2);
			s32 width = lua.getInt(base + 3);
			s32 height = lua.getInt(base + 4);
			pSelectable->setClickLeft(x);
			pSelectable->setClickTop(y);
			pSelectable->setClickWidth(width);
			pSelectable->setClickHeight(height);
		}
		break;
	case FORM_UIS_SET_STICK:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			bool stick = lua.getBool(base + 1);
			pSelectable->setSticked(stick);
		}
		break;
	case FORM_UIS_SET_RADIO:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			int radioID = lua.getInt(base + 1);
			pSelectable->setRadio(radioID);
		}
		break;
	case FORM_UIS_GET_STICK:
		{
			if(argc != base) {
				result = false;
				break;
			}
			bool sticked = pSelectable->isSticked();
			lua.retBoolean(sticked);
			ret = 1;
		}
		break;
	case FORM_UIS_SET_CALLBACK:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}

			const char* newFct = NULL;
			if (lua.isString(base+1)) {
				newFct = lua.getString(base + 1);
			}
			pSelectable->setLuaFunction(newFct);
		}
		break;
	}
	return result;
}