Exemple #1
0
bool
CKLBUpdateZip::initScript(CLuaState& lua)
{
	// bool res = true;

	int argc = lua.numArgs();

	// 引数チェック
	if(argc < ARG_ZIPREQUIRE || argc > ARG_ZIPNUM) {
		return false;
	}

	const char * callbackUnzip		= (argc >= ARG_ZIPUNZIP_CALLBACK)   ? lua.getString(ARG_ZIPUNZIP_CALLBACK)  : NULL;
	const char * callbackFinish		= (argc >= ARG_ZIPFINISH_CALLBACK)  ? lua.getString(ARG_ZIPFINISH_CALLBACK) : NULL;
	const char * callbackError		= (argc >= ARG_ZIPERROR_CALLBACK)   ? lua.getString(ARG_ZIPERROR_CALLBACK)  : NULL;
	
	const char * tmp_name			= lua.getString(ARG_ZIPTMPNAME);
	m_tmpPath						= CKLBUtility::copyString(tmp_name);

	// Load "Update" info if any
	if (lockExist()) {
		m_eStep = S_INIT_UNZIP;

		m_zipEntry			= 0;
		m_callbackZIP		= CKLBUtility::copyString(callbackUnzip);
		m_callbackFinish	= CKLBUtility::copyString(callbackFinish);
		m_callbackError		= callbackError ? CKLBUtility::copyString(callbackError) : NULL;

		return regist(NULL, P_NORMAL);
	} else {
		return false;
	}
}
Exemple #2
0
bool
CKLBUIScore::initUI(CLuaState& lua)
{
	int argc = lua.numArgs();

	// 引数の数が合わない場合
    if(argc < ARG_REQUIRE || argc > ARG_NUMS) { return false; }

	float   x            = lua.getFloat(ARG_X);
	float   y            = lua.getFloat(ARG_Y);
	u32     order        = lua.getInt(ARG_ORDER);
	s32     order_offset = lua.getInt(ARG_ODOFF);
	float   stepX        = lua.getFloat(ARG_STEP_X);
	float   stepY        = lua.getFloat(ARG_STEP_Y);
	int     column       = lua.getInt(ARG_COLS);
	bool    fillzero     = lua.getBool(ARG_FILLZERO);
	bool    anim_flag    = lua.getBool(ARG_ANIM);
	int     align        = (argc >= ARG_ALIGN)     ? lua.getInt(ARG_ALIGN)      : ALIGN_RIGHT;
	bool    countclip    = (argc >= ARG_COUNTCLIP) ? lua.getBool(ARG_COUNTCLIP) : false;

	const char * tex_list[10];
	lua.retValue(ARG_TEXTBL);	// 対象となる配列をスタックトップに積む
	lua.retNil();				// nil をスタックトップに積む
	int tex_cnt = 0;
	while(lua.tableNext()) {
		lua.retValue(-2);
		int idx = lua.getInt(-1) - 1;			// Lua配列の添え字は1からなので、-1する。
		const char * str = lua.getString(-1);

		// 与えられた配列のindexに整数以外が使われているときや、
		// 範囲を超えたものがある場合はエラー扱いとする。
		klb_assert((idx >= 0 && idx <= 9), "BAD INDEX [%s] in texture array.", str);
		if(idx < 0 || idx > 9) {	// 数値以外のインデックスが指定されていたり、範囲を超えている場合
			return false;
		}
		const char * texname = lua.getString(-2);	// テクスチャ名称が格納されている。
		tex_list[idx] = texname;
		tex_cnt++;
		lua.pop(2);
	}
	lua.pop(1);
	// テクスチャの数が足りなければエラーとする。
	if(tex_cnt != 10) {
		klb_assert(tex_cnt == 10, "%s(%d): The number of textures is insufficient. ", lua.getScriptName(), lua.getNumLine()); 
		return false;
	}

	return initCore(order, order_offset, x, y, tex_list, stepX, stepY, column, fillzero, anim_flag, align, countclip);
}
Exemple #3
0
bool
CKLBFormIF::updateUITextEdit(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBUITask* pTask		= pNode->getUITask();
	CKLBUITextBox * pText	= (CKLBUITextBox *)pNode;

    // 2012-12-3(Mon)
    // pTaskが存在していない可能性が高いのでpTaskのNULLチェックを追加しました
	if ((pTask) && (pTask->getClassID() != CLS_KLBUITEXTINPUT)) {
		// Not valid
		pTask = NULL;
	}

	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_LBL_GET_TEXT:	// Trick : label & text command backward compatible.
	case FORM_TEXT_GET:
		{
			/* Do not understand why return false for now.
			if(argc != base) {
				result = false;
				break;
			}*/
			const char * text;

			if (pTask) {
				text = ((CKLBUITextInput*)pTask)->getText();
			} else {
				text = pText->getText();
			}

			lua.retString(text);
			ret = 1;
		}
		break;
	case FORM_TEXT_SET:	// Trick : label & text command backward compatible.
	case FORM_LBL_SET_TEXT:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * text = lua.getString(base + 1);
			
			if (pTask) {
				((CKLBUITextInput*)pTask)->setText(text);
			} else {
				pText->setText((char *)text);
			}
		}
		break;
	}
	return result;
}
bool
CKLBGenericTask::initScript(CLuaState &lua)
{
    int argc = lua.numArgs();
    if(argc < ARGS_REQUIRE || argc > ARGS_MAX) {
        return false;
    }

    const char * name_exec = lua.getString(ARGS_EXEC);
    const char * name_die  = lua.getString(ARGS_DIE);
    const char * arr_index = lua.getString(ARGS_ARRAY);
    CKLBTask::TASK_PHASE phase = (CKLBTask::TASK_PHASE)((argc >= ARGS_PHASE) ? lua.getInt(ARGS_PHASE) : P_NORMAL);
    CKLBTask * pParent = (argc >= ARGS_PARENT) ? (CKLBTask *)lua.getPointer(ARGS_PARENT) : NULL;

    return init(pParent, phase, name_exec, name_die, arr_index);
}
Exemple #5
0
bool
CKLBUIMultiImgItem::getImgList(CLuaState& lua, IMGITEM* items, u32 /*max*/)
{
	CKLBRenderingManager& rdr = CKLBRenderingManager::getInstance();

	lua.retNil();
	while(lua.tableNext()) {
		lua.retValue(-2);
		int idx = lua.getInt(-1) - 1;
		const char * name = lua.getString(-2);
		lua.pop(2);

		u32 handle;
		CKLBAsset * pAsset = CKLBUtility::loadAsset(name, &handle, NULL);
		if(pAsset->getAssetType() == ASSET_IMAGE) {
			CKLBSprite*	pRender	= rdr.allocateCommandSprite((CKLBImageAsset*)pAsset,m_order);

			items[idx].handle = handle;
			items[idx].sprite = pRender;
		}

	}

	return true;
}
Exemple #6
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;
}
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;
}
Exemple #8
0
bool
CKLBFormIF::updateLabelNode(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBLabelNode * pLabel = (CKLBLabelNode *)pNode;
	CKLBUITask* pTask		= pNode->getUITask();

    // pTaskが存在していない可能性が高いのでpTaskのNULLチェックを追加しました
	if ((pTask) && (pTask->getClassID() != CLS_KLBUILABEL)) {
		// Not valid
		pTask = NULL;
	}

	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_TEXT_SET:	// Trick : label & text command backward compatible.
	case FORM_LBL_SET_TEXT:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * text = lua.getString(base + 1);
			if (pTask) {
				((CKLBUILabel*)pTask)->setText(text);
			} else {
				pLabel->setText((char *)text);
			}
		}
		break;
	case FORM_LBL_GET_TEXT:	// Trick : label & text command backward compatible.
	case FORM_TEXT_GET:
		{
			/*
			if(argc != base) {
				result = false;
				break;
			}*/
			const char * uri;
			if (pTask) {
				uri = ((CKLBUILabel*)pTask)->getText();
			} else {
				uri = pLabel->getText();
			}
			lua.retString(uri);
			ret = 1;
		}
		break;
	}
	return result;
}
Exemple #9
0
bool
CKLBUIButton::initScript(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc < ARG_REQUIRE || argc > ARG_NUMS) return false;

	const char * funcname = lua.getString(ARG_CALLBACK);

	return init(NULL, funcname);
}
bool
CKLBUISimpleItem::initUI(CLuaState& lua)
{
	int argc = lua.numArgs();
    if(argc < ARG_REQUIRE || argc > ARG_NUMS) { return false; }

	float x = lua.getFloat(ARG_X);
	float y = lua.getFloat(ARG_Y);

	return initCore(lua.getInt(ARG_ORDER),x,y,lua.getString(ARG_ASSET));
} 
Exemple #11
0
bool
CKLBUIControl::initScript(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc != 2) return false;

	const char * onClick = lua.getString(1);
	const char * onDrag  = lua.getString(2);

	return init(NULL, onClick, onDrag);
}
Exemple #12
0
bool
CKLBUITouchPad::initScript(CLuaState& lua)
{
	int argc = lua.numArgs();
    if(argc < ARG_REQUIRE || argc > ARG_NUMS) { return false; }

	const char * funcname = lua.getString(ARG_CALLBACK);
	bool modal = (argc >= ARG_MODAL) ? lua.getBool(ARG_MODAL) : false;

	return init(NULL, funcname, modal);
}
Exemple #13
0
bool
CKLBPauseCtrl::initScript(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc != 2) {
		return false;
	}
	const char * pause  = (lua.isNil(1)) ? NULL : lua.getString(1);
	const char * resume = (lua.isNil(2)) ? NULL : lua.getString(2);
	
	return init(NULL, pause, resume);
}
Exemple #14
0
bool
CKLBFormIF::updateUIWebView(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * item, int index)
{
	CKLBUITask* pTask		= pNode->getUITask();
	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = updateUIElement(lua, argc, base, subcmd, pNode, ret, item, index);
		}
		break;
	case FORM_WEB_SET_URI:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * uri = lua.getString(base + 1);
			if (pTask) {
				CKLBUIWebArea* pWebTask = (CKLBUIWebArea*)pTask;
				pWebTask->setText(uri);
			} else {
				CKLBUIWebView * pWeb = (CKLBUIWebView *)pNode;
				pWeb->setText((char *)uri);
			}
		}
		break;
	case FORM_WEB_GET_URI:
		{
			if(argc != base) {
				result = false;
				break;
			}
			const char * uri;
			if (pTask) {
				CKLBUIWebArea* pWebTask = (CKLBUIWebArea*)pTask;
				uri = pWebTask->getText();
			} else {
				CKLBUIWebView * pWeb = (CKLBUIWebView *)pNode;
				uri = pWeb->getText();
			}

			lua.retString(uri);
			ret = 1;
		}
		break;
	}
	return result;
}
Exemple #15
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;
}
Exemple #16
0
bool
CKLBUpdate::initScript(CLuaState& lua)
{
	// bool res = true;

	int argc = lua.numArgs();

	// 引数チェック
	if(argc < ARG_REQUIRE || argc > ARG_NUM) {
		return false;
	}

	const char * callbackDownload	= (argc >= ARG_DOWNLOAD_CALLBACK)	? lua.getString(ARG_DOWNLOAD_CALLBACK)	: NULL;
	const char * callbackUnzip		= (argc >= ARG_UNZIP_CALLBACK)		? lua.getString(ARG_UNZIP_CALLBACK)		: NULL;
	const char * callbackFinish		= (argc >= ARG_FINISH_CALLBACK)		? lua.getString(ARG_FINISH_CALLBACK)	: NULL;
	const char * callbackError		= (argc >= ARG_ERROR_CALLBACK)		? lua.getString(ARG_ERROR_CALLBACK)		: NULL;
	
	const char * zip_url;
	const char * zip_size;
	const char * tmp_name;
	zip_url				= lua.getString(ARG_ZIPURL);
	zip_size			= lua.getString(ARG_ZIPSIZE);	// サイズは狂いがあると困るのでstringで受ける
	tmp_name			= lua.getString(ARG_TMPNAME);

	m_tmpPath			= CKLBUtility::copyString(tmp_name);
	m_zipURL			= CKLBUtility::copyString(zip_url);
	m_zipSize			= CKLBUtility::stringNum64(zip_size);

	m_eStep	= S_INIT_DL;
	// Start from scratch and download
	m_dlSize			= -1;
	m_zipEntry			= 0;
	m_callbackDL		= CKLBUtility::copyString(callbackDownload);
	m_callbackZIP		= CKLBUtility::copyString(callbackUnzip);
	m_callbackFinish	= CKLBUtility::copyString(callbackFinish);
	m_callbackError		= callbackError ? CKLBUtility::copyString(callbackError) : NULL;

	return regist(NULL, P_NORMAL);
}
Exemple #17
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;
}
Exemple #18
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;
}
Exemple #19
0
bool
CKLBFormIF::updateStandardNode(CLuaState& lua, int argc, int base, int subcmd, CKLBNode * pNode, int& ret, void * /*item*/, int index)
{
	bool result = true;
	switch(subcmd)
	{
	default:
		{
			result = false;
		}
		break;
	case FORM_NODE_POINTER:
		{
			if(argc != base) {
				lua.retNil();
				ret = 1;
				break;
			}
			lua.retPointer(pNode);
			ret = 1;
		}
		break;

	case FORM_NODE_RECURSIVE:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			const char * funcname = lua.getString(base + 1);	// コールバック名の取得
			result = nodeRecursive(lua, funcname, pNode, index);
		}
		break;

	case FORM_NODE_TRANS:
		{
			if(argc != (base + 2)) {
				result = false;
				break;
			}
			float x = lua.getFloat(base + 1);
			float y = lua.getFloat(base + 2);

			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				// Change next frame or current frame.
				if(pTask->isNewScriptModel()) {
					pTask->setX(x);
					pTask->setY(y);
				} else {
					int idxX = pTask->findProperty("x");
					int idxY = idxX + 1;
					pTask->setNum(idxX, x);
					pTask->setNum(idxY, y);
				}
				// Trick: we modify directly the node AND change the property.
				// If another property is modified later, it will force the value to be used. 
				// ==> Do not execute pTask->setInnerUpdate();
			}
			// But changes also RIGHT AWAY
			pNode->setTranslate(x, y);
		}
		break;
	case FORM_NODE_SCALE:
		{
			if(argc != base + 2) {
				result = false;
				break;
			}
			float scaleX = lua.getFloat(base + 1);
			float scaleY = lua.getFloat(base + 2);

			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				if(pTask->isNewScriptModel()) {
					pTask->setScaleX(scaleX);
					pTask->setScaleY(scaleY);
				} else {
					int idxX = pTask->findProperty("scaleX");
					int idxY = idxX + 1;
					pTask->setNum(idxX, scaleX);
					pTask->setNum(idxY, scaleY);
				}
				// Trick: we modify directly the node AND change the property.
				// If another property is modified later, it will force the value to be used. 
				// ==> Do not execute pTask->setInnerUpdate();
			}
			pNode->setScale(scaleX, scaleY);
		}
		break;
	case FORM_NODE_ROT:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			float rot = lua.getFloat(base + 1);

			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				if(pTask->isNewScriptModel()) {
					pTask->setRotation(rot);
				} else {
					int idxRot = pTask->findProperty("rot");
					pTask->setNum(idxRot, rot);
				}
				pTask->setInnerUpdate();
				// Trick: we modify directly the node AND change the property.
				// If another property is modified later, it will force the value to be used. 
				// ==> Do not execute pTask->setInnerUpdate();
			}
			pNode->setRotation(rot);
		}
		break;
	case FORM_NODE_COLOR:
		{
			if(argc != base + 2) {
				result = false;
				break;
			}

			u32 alpha = lua.getInt(base + 1);
			u32 rgb   = lua.getInt(base + 2);

			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				if(pTask->isNewScriptModel()) {
					pTask->setAlpha(alpha);
					pTask->setArgb(rgb);
				} else {
					int idxcol = pTask->findProperty("alpha");	// Color just after !
					pTask->setInt(idxcol, alpha);
					pTask->setInt(idxcol+1, rgb);
				}
				pTask->setInnerUpdate();
			}

			SColorVector color;
			color.m_type = 0;

			for(int i = 0; i < 3; i++) {
				int col = 0xff & (rgb >> (16 - 8 * i));
				color.m_vector[i] = col / 255.0f;
			}
			color.m_vector[3] = (alpha & 0xff) / 255.0f;
			pNode->setColorMatrix(color);
		}
		break;
	case FORM_NODE_VISIBLE:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			bool visible = lua.getBool(base + 1);

			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				pTask->setVisible(visible);
			} else {
				pNode->setVisible(visible);
			}
		}
		break;
	case FORM_NODE_ORDER:
		{
			if(argc != base + 1) {
				result = false;
				break;
			}
			int order = lua.getInt(base + 1);
			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				if(pTask->isNewScriptModel()) {
					pTask->setOrder(order);
					pTask->setInnerUpdate();
				} else {
					int idx_order = pTask->findProperty("order");
					if (idx_order >= 0) {
						pTask->setInt(idx_order, order);
						pTask->setInnerUpdate();
					}
				}
			}
			pNode->setPriority(order);
			pNode->markUpMatrix();
		}
		break;
	case FORM_NODE_GET_ORDER:
		{
			if(argc != base) {
				result = false;
				break;
			}
			int order;
			CKLBUITask* pTask = pNode->getUITask();
			if (pTask) {
				if(pTask->isNewScriptModel()) {
					order = pTask->getOrder();
				} else {
					int idx_order = pTask->findProperty("order");
					if (idx_order >= 0) {
						order = pTask->getInt(idx_order);
					} else {
						order = 0;
					}
				}
			} else {
				order = pNode->getPriority();
			}
			lua.retInt(order);
			ret = 1;
		}
		break;

	case FORM_NODE_TASK:
		{
			if(argc != base) {
				result = false;
				break;
			}
			CKLBUITask * pTask = pNode->getUITask();
			if(!pTask) {
				lua.retNil();
			} else {
				lua.retPointer(pTask);
			}
			ret = 1;
		}
		break;
	}
	return result;
}
Exemple #20
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;
}