Ejemplo n.º 1
0
int
CKLBUIMultiImgItem::commandUI(CLuaState& lua, int argc, int cmd)
{
	int ret = 0;
	switch(cmd)
	{
	default:
		{
			lua.retBoolean(false);
			ret = 1;
		}
		break;
	case UI_MULTIIMG_SET_INDEX:
		{
			if(argc != 3) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			int idx = lua.getInt(3);
			// 指定されたindexが有効な範囲に収まらなければ、何もせずfalseを返す
			int max = m_idxMax;
			if(idx > max || idx < 0) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			setIndex(idx);
			lua.retBoolean(true);
			ret = 1;
		}
		break;
	}
	return ret;
}
Ejemplo n.º 2
0
int
CKLBLifeCtrlTask::commandScript(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc < 2) {
		lua.retBoolean(false);
		return 1;
	}
	int cmd = lua.getInt(2);
	int ret = 1;

	switch(cmd)
	{
	default:
		{
			lua.retBoolean(false);
			ret = 1;
		}
		break;
	case LIFECTRL_ADD_CHILD:
		{
			if(argc != 3) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			CKLBTask * pTask = (CKLBTask *)lua.getPointer(3);
			child(pTask);	// 自身の子として登録
		}
		break;
	}
	return ret;
}
Ejemplo n.º 3
0
int
CKLBGenericTask::commandScript(CLuaState& lua)
{
    int argc = lua.numArgs();
    if(argc < 2) {
        lua.retBoolean(false);
        return 1;
    }
    int cmd = lua.getInt(2);
    int ret = 1;

    switch(cmd)
    {
    default:
    {
        lua.retBoolean(false);
        ret = 1;
    }
    break;
    case GENERIC_STOP_EXECUTE:
    {
        KLBDELETEA(m_luaFuncExec);
        m_luaFuncExec = NULL;
        lua.retBoolean(true);
        ret = 1;
    }
    break;
    }
    return ret;
}
Ejemplo n.º 4
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.º 5
0
int
CKLBUITouchPad::commandScript(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc < 2) {
		lua.retBool(false);
		return 1;
	}

	int cmd = lua.getInt(2);
	int ret = 1;
	switch(cmd)
	{
	default:
		{
			lua.retBool(false);
			ret = 1;
		}
		break;
	case UI_TOUCHPAD_SET_GROUP:
		{
			bool result = false;
			if(argc == 3) {
				const char * group_name = lua.getString(3);
				result = setGroup(group_name);
			}
			lua.retBoolean(result);
			ret = 1;
		}
		break;
	case UI_TOUCHPAD_LOCK:
		{
			bool result = false;
			if(argc == 3) {
				bool lock_mode = lua.getBool(3);
				lock(lock_mode);
				result = true;
			}
			lua.retBoolean(true);
			ret = 1;
		}
		break;
	case UI_TOUCHPAD_GET_ALL:
		{
			bool result = false;
			if(argc == 3) {
				setGetAll(lua.getBool(3));
				result = true;
			}
			lua.retBoolean(result);
			ret = 1;
		}
		break;
	}
	return ret;
}
Ejemplo n.º 6
0
bool
CKLBFormIF::updateUIElement(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBUIElement * pElement = (CKLBUIElement *)pNode;
	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateStandardNode(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_UIE_SET_ENABLED:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			bool enable = lua.getBool(base + 1);
			pElement->setEnabled(enable);
		}
		break;
	case FORM_UIE_GET_ENABLED:
		{
			if(argc != base) {
				result = false;
				break;
			}
			bool enable = pElement->isEnabled();
			lua.retBoolean(enable);
			ret = 1;
		}
		break;
	case FORM_UIE_SET_ASSET:
		{
			if(argc != base + 2) {
				result = false;
				break;
			}
			const char * asset = (!lua.isNil(base + 1)) ? lua.getString(base + 1) : NULL;
			const int mode = lua.getInt(base + 2);
			CKLBAsset * pAsset = updateAsset(lua, pElement, asset, (CKLBUIElement::ASSET_TYPE)mode, item);
			bool result = (!pAsset) ? false : true;
			lua.retBoolean(result);
			ret = 1;
		}
		break;
	}
	return result;
}
Ejemplo n.º 7
0
int
CKLBUIControl::commandScript(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc < 2) {
		lua.retBoolean(false);
		return 1;
	}
	int ret = 1;
	int cmd = lua.getInt(2);
	switch(cmd)
	{
	default:
		{
			ret = 1;
			lua.retBoolean(false);
		}
		break;
	case UI_CONTROL_ON_PINCH:
		{
			ret = 1;
			if(argc != 3) {
				lua.retBoolean(false);
				break;
			}
			const char * onPinch = lua.getString(3);
			if(!onPinch) {
				lua.retBoolean(false);
				break;
			}
			m_onPinch = CKLBUtility::copyString(onPinch);
			if(!onPinch) {
				lua.retBoolean(false);
				break;
			}
			lua.retBoolean(true);
		}
		break;
    case UI_CONTROL_ON_DBLCLICK:
		{
			ret = 1;
			if(argc != 3) {
				lua.retBoolean(false);
				break;
			}
			const char * onDblClick = lua.getString(3);
			if(!onDblClick) {
				lua.retBoolean(false);
				break;
			}
			setOnDblClick(onDblClick);
			if(!onDblClick) {
				lua.retBoolean(false);
				break;
			}
			lua.retBoolean(true);
		}
        break;
	case UI_CONTROL_ON_LONGTAP:
		{
			ret = 1;
			if(argc != 3) {
				lua.retBoolean(false);
				break;
			}
			const char * onLongTap = lua.getString(3);
			setOnLongTap(onLongTap);
			if(!onLongTap) {
				lua.retBoolean(false);
				break;
			}
			lua.retBoolean(true);
		}
		break;
	case UI_CONTROL_ON_RAWEVENT:
		{
			ret = 1;
			if(argc != 3) {
				lua.retBoolean(false);
				break;
			}
			const char * onRawEvent = lua.getString(3);
			setOnEventRaw(onRawEvent);
			if(!onRawEvent) {
				lua.retBoolean(false);
				break;
			}
			lua.retBoolean(true);
		}
		break;
	case UI_CONTROL_SET_GROUP:
		{
			bool result = false;
			if(argc == 3) {
				const char * group_name = lua.getString(3);
				ret = setGroup(group_name);
			}
			lua.retBoolean(result);
			ret = 1;
		}
		break;
		/*
	case UI_CONTROL_LOCK:
		{
			bool result = false;
			if(argc == 3) {
				bool lock_mode = lua.getBool(3);
				lock(lock_mode);
				result = true;
			}
			lua.retBoolean(result);
			ret = 1;
		}
		break;
		*/
	case UI_CONTROL_SET_MASK:
		{
			bool result = false;
			if(argc == 3) {
				u16 mask = lua.getInt(3);
				m_callbackMask = mask;
				result = true;
			}
			lua.retBoolean(result);
			ret = 1;
		}
		break;
	case UI_CONTROL_GET_ALL:
		{
			bool result = false;
			if(argc == 3) {
				setGetAll(lua.getBool(3));
				result = true;
			}
			lua.retBoolean(result);
			ret = 1;
		}
		break;
	}
	return ret;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
0
int
CKLBUIScore::commandUI(CLuaState& lua, int argc, int cmd)
{
	int ret = 0;
	switch(cmd)
	{
	case UI_SCORE_RESET:
		setValue(0);
		m_bScoreUpdate = true;
		break;
	case UI_SCORE_SET:
		{
			if(argc != 3) {
				lua.retNil();
				ret = 1;
				break;
			}
			int value = lua.getInt(3);
			if(m_bCountClip && value >= m_maxvalue) value = m_maxvalue - 1;
			setValue(value);
		}
		break;
	case UI_SCORE_SETFLOAT:
		{
			if(argc != 4) {
				lua.retNil();
				ret = 1;
				break;
			}
			float value = lua.getFloat(3);
			int pos = lua.getInt(4);
			if(m_bCountClip && value >= m_maxvalue) value = m_maxvalue - 1;
			setValueFloat(value, pos);
		}
		break;
	case UI_SCORE_SETDOT:
		{
			if(argc != 5) {
				lua.retNil();
				ret = 1;
				break;
			}

			setDot(lua.getString(3), lua.getInt(4), lua.getInt(5));
		}
		break;
	case UI_SCORE_GET:
		{	
			int value = getValue();
			lua.retInt(value);
			ret = 1;
		}
		break;
	case UI_SCORE_ENTERANIM:
		{
			if(argc != 8) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			s32  mspt       = lua.getInt(3);
			s32  tshift     = lua.getInt(4);
			bool onlychg    = lua.getBool(5);
			int  type       = lua.getInt(6);
			u32  affected   = lua.getInt(7);
			float mat[8];
			klb_assert(type > 0, "UI_Score: UI_SCORE_ENTERANIM type == 0");

			// 配列を読む
			lua.retValue(8);
			lua.retNil();
			while(lua.tableNext()) {
				lua.retValue(-2);
				int idx = lua.getInt(-1) - 1;
				klb_assert((idx >= 0 && idx < 8), "%s(%d): bad array index. UI_SCORE_ENTERANIM", lua.getScriptName(), lua.getNumLine());
				mat[idx] = lua.getFloat(-2);
				lua.pop(2);
			}
			lua.pop(1);

			klb_assert(type != 0, "Custom animation is not authorized (type 0)");
			m_pScoreNode->setEnterAnimation(mspt, tshift, onlychg, type, affected, mat);
		}
		break;
	case UI_SCORE_EXITANIM:
		{
			if(argc != 8) {
				lua.retBoolean(false);
				ret = 1;
				break;
			}
			s32  mspt       = lua.getInt(3);
			s32  tshift     = lua.getInt(4);
			bool onlychg    = lua.getBool(5);
			int  type       = lua.getInt(6);
			u32  affected   = lua.getInt(7);
			float mat[4];
			klb_assert(type > 0, "UI_Score: UI_SCORE_ENTERANIM type == 0");

			// 配列を読む
			lua.retValue(8);
			lua.retNil();
			while(lua.tableNext()) {
				lua.retValue(-2);
				int idx = lua.getInt(-1) - 1;
				mat[idx] = lua.getFloat(-2);
				lua.pop(2);
			}
			lua.pop(1);

			klb_assert(type != 0, "Custom animation is not authorized (type 0)");
			m_pScoreNode->setExitAnimation(mspt, tshift, onlychg, type, affected, mat);
		}
		break;
	case UI_SCORE_ALIGN:
		{
			bool bResult = false;
			if(argc == 3) {
				int align = lua.getInt(3);
				setAlign(align);
				bResult = true;
			}
			lua.retBool(bResult);
			ret = 1;
		}
		break;
	}
	return ret;
}