コード例 #1
0
int CLuaInstProgressWindow::CProgressWindowPaint(lua_State *L)
{
	lua_assert(lua_istable(L,1));
	CLuaCProgressWindow *D = CProgressWindowCheck(L, 1);
	if (!D) return 0;

	bool do_save_bg = true;
	if (!tableLookup(L, "do_save_bg", do_save_bg)) {
		std::string tmp = "true";
		if (tableLookup(L, "do_save_bg", tmp))
			paramBoolDeprecated(L, tmp.c_str());
		do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
	}
	D->w->paint(do_save_bg);
	return 0;
}
コード例 #2
0
ファイル: lua_cc_text.cpp プロジェクト: dbt1/neutrino-mp
int CLuaInstCCText::CCTextEnableUTF8(lua_State *L)
{
	lua_assert(lua_istable(L,1));
	CLuaCCText *D = CCTextCheck(L, 1);
	if (!D) return 0;

	bool utf8_encoded = true;
	if (!tableLookup(L, "utf8_encoded", utf8_encoded)) {
		std::string tmp = "true";
		if (tableLookup(L, "utf8_encoded", tmp))
			paramBoolDeprecated(L, tmp.c_str());
		utf8_encoded = (tmp == "true" || tmp == "1" || tmp == "yes");
	}
	D->ct->enableUTF8(utf8_encoded);
	return 0;
}
コード例 #3
0
ファイル: lua_cc_text.cpp プロジェクト: dbt1/neutrino-mp
int CLuaInstCCText::CCTextNew(lua_State *L)
{
	lua_assert(lua_istable(L,1));

	CLuaCCWindow* parent = NULL;
	lua_Integer x=10, y=10, dx=-1, dy=-1;
	std::string text = "";
	std::string tmpMode       = "";
	lua_Integer mode          = CTextBox::AUTO_WIDTH;
	lua_Integer font_text     = SNeutrinoSettings::FONT_TYPE_MENU;
	lua_Unsigned color_text   = (lua_Unsigned)COL_MENUCONTENT_TEXT;
	lua_Unsigned color_frame  = (lua_Unsigned)COL_FRAME_PLUS_0;
	lua_Unsigned color_body   = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
	lua_Unsigned color_shadow = (lua_Unsigned)COL_SHADOW_PLUS_0;

	tableLookup(L, "parent",    (void**)&parent);
	tableLookup(L, "x",         x);
	tableLookup(L, "y",         y);
	tableLookup(L, "dx",        dx);
	tableLookup(L, "dy",        dy);
	tableLookup(L, "text",      text);
	tableLookup(L, "mode",      tmpMode);
	tableLookup(L, "font_text", font_text);
	if (font_text >= SNeutrinoSettings::FONT_TYPE_COUNT || font_text < 0)
		font_text = SNeutrinoSettings::FONT_TYPE_MENU;

	lua_Integer shadow_mode = CC_SHADOW_OFF;
	if (!tableLookup(L, "has_shadow", shadow_mode)) {
		std::string tmp1 = "false";
		if (tableLookup(L, "has_shadow", tmp1))
			paramBoolDeprecated(L, tmp1.c_str());
		shadow_mode = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
	}

	tableLookup(L, "color_text",   color_text);
	tableLookup(L, "color_frame",  color_frame);
	tableLookup(L, "color_body",   color_body);
	tableLookup(L, "color_shadow", color_shadow);

	color_text   = checkMagicMask(color_text);
	color_frame  = checkMagicMask(color_frame);
	color_body   = checkMagicMask(color_body);
	color_shadow = checkMagicMask(color_shadow);

	if (!tmpMode.empty()) {
		table_key txt_align[] = {
			{ "ALIGN_AUTO_WIDTH",		CTextBox::AUTO_WIDTH },
			{ "ALIGN_AUTO_HIGH",		CTextBox::AUTO_HIGH },
			{ "ALIGN_SCROLL",		CTextBox::SCROLL },
			{ "ALIGN_CENTER",		CTextBox::CENTER },
			{ "ALIGN_RIGHT",		CTextBox::RIGHT },
			{ "ALIGN_TOP",			CTextBox::TOP },
			{ "ALIGN_BOTTOM",		CTextBox::BOTTOM },
			{ "ALIGN_NO_AUTO_LINEBREAK",	CTextBox::NO_AUTO_LINEBREAK },
			{ "DECODE_HTML",		0 },
			{ NULL,				0 }
		};
		mode = 0;
		for (int i = 0; txt_align[i].name; i++) {
			if (tmpMode.find(txt_align[i].name) != std::string::npos)
				mode |= txt_align[i].code;
		}
		if (tmpMode.find("DECODE_HTML") != std::string::npos)
			htmlEntityDecode(text);
	}

	CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
	if(pw){
		if(dy < 1)
			dy = pw->getHeight();
		if(dx < 1)
			dx = pw->getWidth();
	}
	if(dx < 1)
		dx = 100;
	if(dy < 1)
		dy = 100;

	CLuaCCText **udata = (CLuaCCText **) lua_newuserdata(L, sizeof(CLuaCCText *));
	*udata = new CLuaCCText();
	(*udata)->ct = new CComponentsText(x, y, dx, dy, text, mode, g_Font[font_text], 0 /*TODO: style not passed*/, pw, shadow_mode, (fb_pixel_t)color_text, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow);
	(*udata)->parent = pw;
	(*udata)->mode = mode;
	(*udata)->font_text = font_text;
	luaL_getmetatable(L, "ctext");
	lua_setmetatable(L, -2);
	return 1;
}