PS::PickState(Main &main, OCamlBinding &ocaml)
	: _main(main)
	, _ocaml(ocaml)
	, _b(loadBundle(main, ocaml))
	, _launchSolvingState(false)
{
	lua_State	*l = this->_b->act.getLuaState();
	auto		*bun = this->_b;
	auto		&act = bun->act;
	int			ret;
// TODO: ftlua
	ret = lua_getglobal(l, "PickState");
	FTASSERT(ret == LUA_TTABLE);

	lua_pushinteger(l, 0);
	lua_pushlightuserdata(l, this);
	lua_settable(l, -3);

	lua_pop(l, 1);
	act.fireEvent("GRID_LIST_UPDATE", bun->extractGridNames()
						, bun->grids.size());
	act.fireEvent("SELECTED_GRID_CHANGED", bun->selectedId);

	act.fireEvent("Bordel", 42, std::string("caca"));

	act.queryRedrawAll();

	return ;
}
RS::ResultState(Main &main, OCamlBinding &ocaml, ISolverListener::report_s r)
	: _main(main)
	, _ocaml(ocaml)
	, _b(loadBundle(main, ocaml))
	, _leave(false)
{
	lua_State	*l = this->_b->act.getLuaState();
	auto		*bun = this->_b;
	auto		&act = bun->act;
	int			ret;
// TODO: ftlua
	ret = lua_getglobal(l, "ResultState");
	FTASSERT(ret == LUA_TTABLE);

	lua_pushinteger(l, 0);
	lua_pushlightuserdata(l, this);
	lua_settable(l, -3);

	lua_pop(l, 1);
	// act.fireEvent("GRID_LIST_UPDATE", bun->extractGridNames()
	// 					, bun->grids.size());
	act.fireEvent("RESULT_DATA", r.time, r.g, r.init_h, r.avg_h, r.nodes
				  , r.max_open, r.max_closed, r.max_both, r.steps);

	// act.fireEvent("Bordel", 42, std::string("caca"));

	act.queryRedrawAll();

	return ;
}
Esempio n. 3
0
uint16_t GX::Stage::acquireBundle(uint64_t permanentBundleID)
{
	uint16_t bundleIndex = loadedBundles.size();
	for (uint16_t i = 0; i < loadedBundles.size(); i++)
	{
		if (loadedBundles[i].referenceCount and loadedBundles[i].permanentBundleID == permanentBundleID)
		{
			loadedBundles[i].referenceCount++;
			return i;
		}
		bundleIndex = std::min(i, bundleIndex);
	}
	
	if (loadedBundles.size() == bundleIndex)
		loadedBundles.push_back(LoadedBundle());
	
	loadedBundles[bundleIndex].referenceCount++;
	loadedBundles[bundleIndex].permanentBundleID = permanentBundleID;
	
	//Do actual loading
	loadBundle(bundleIndex);
	
	return bundleIndex;
}