Пример #1
0
static void help(const char* msg = NULL)
{
	if (msg)
	{
		CE_LOGE("Error: %s\n", msg);
	}

	CE_LOGI(
		"Usage: crown [options]\n"
		"\n"
		"Options:\n"
		"\n"
		"  -h --help                  Display this help.\n"
		"  -v --version               Display engine version.\n"
		"  --source-dir <path>        Use <path> as the source directory for resource compilation.\n"
		"  --bundle-dir <path>        Use <path> as the destination directory for compiled resources.\n"
		"  --boot-dir <path>          Boot the engine with the 'boot.config' from given <path>.\n"
		"  --compile                  Do a full compile of the resources.\n"
		"  --platform <platform>      Compile resources for the given <platform>.\n"
		"      linux\n"
		"      windows\n"
		"      android\n"
		"  --continue                 Run the engine after resource compilation.\n"
		"  --console-port <port>      Set port of the console.\n"
		"  --wait-console             Wait for a console connection before starting up.\n"
		"  --parent-window <handle>   Set the parent window <handle> of the main window.\n"
	);
}
Пример #2
0
void Device::init()
{
    // Initialize
    CE_LOGI("Initializing Crown Engine %s...", version());

    // Create resource manager
    CE_LOGD("Creating resource manager...");
    _resource_manager = CE_NEW(_allocator, ResourceManager)(_fs);

    CE_LOGD("Creating material manager...");
    material_manager::init();
    debug_line::init();

    _lua_environment = CE_NEW(_allocator, LuaEnvironment)();
    _lua_environment->load_libs();

    CE_LOGD("Crown Engine initialized.");
    CE_LOGD("Initializing Game...");

    _is_init = true;
    _is_running = true;
    _last_time = os::clocktime();

    _boot_package = create_resource_package(_boot_package_id);
    _boot_package->load();
    _boot_package->flush();

    _lua_environment->execute((LuaResource*)_resource_manager->get(SCRIPT_TYPE, _boot_script_id));
    _lua_environment->call_global("init", 0);
}
Пример #3
0
bool BundleCompiler::compile(const char* type, const char* name, const char* platform)
{
	StringId64 _type(type);
	StringId64 _name(name);

	TempAllocator512 alloc;
	DynamicString path(alloc);
	TempAllocator512 alloc2;
	DynamicString src_path(alloc2);

	src_path += name;
	src_path += ".";
	src_path += type;

	char res_name[1 + 2*StringId64::STRING_LENGTH];
	_type.to_string(res_name);
	res_name[16] = '-';
	_name.to_string(res_name + 17);

	path::join(CROWN_DATA_DIRECTORY, res_name, path);

	CE_LOGI("%s <= %s.%s", res_name, name, type);

	bool success = true;
	jmp_buf buf;

	Buffer output(default_allocator());
	array::reserve(output, 4*1024*1024);

	if (!setjmp(buf))
	{
		CompileOptions opts(_source_fs, output, platform, &buf);
		compile(_type, src_path.c_str(), opts);
		File* outf = _bundle_fs.open(path.c_str(), FileOpenMode::WRITE);
		u32 size = array::size(output);
		u32 written = outf->write(array::begin(output), size);
		_bundle_fs.close(*outf);
		success = size == written;
	}
	else
	{
		success = false;
	}

	return success;
}
Пример #4
0
//-----------------------------------------------------------------------------
void Device::init()
{
	// Initialize
	CE_LOGI("Initializing Crown Engine %s...", version());
	_resource_bundle = Bundle::create(_allocator, _fs);

	// Create resource manager
	CE_LOGD("Creating resource manager...");
	_resource_manager = CE_NEW(_allocator, ResourceManager)(*_resource_bundle);

	// Create world manager
	CE_LOGD("Creating world manager...");
	_world_manager = CE_NEW(_allocator, WorldManager)();

	CE_LOGD("Creating material manager...");
	material_manager::init();

	CE_LOGD("Creating lua system...");
	lua_system::init();
	_lua_environment = CE_NEW(_allocator, LuaEnvironment)(lua_system::state());

	CE_LOGD("Crown Engine initialized.");
	CE_LOGD("Initializing Game...");

	_is_init = true;
	_is_running = true;
	_last_time = os::clocktime();

	_boot_package = create_resource_package(_boot_package_id);
	_boot_package->load();
	_boot_package->flush();

	ResourceId bootid;
	bootid.type = LUA_TYPE;
	bootid.name = _boot_script_id;
	_lua_environment->execute((LuaResource*) _resource_manager->get(bootid));
	_lua_environment->call_global("init", 0);
}
Пример #5
0
int DeviceOptions::parse()
{
	CommandLine cl(_argc, _argv);

	if (cl.has_argument("help", 'h'))
	{
		help();
		return EXIT_FAILURE;
	}

	if (cl.has_argument("version", 'v'))
	{
		CE_LOGI(CROWN_VERSION_STRING);
		return EXIT_FAILURE;
	}

	_bundle_dir = cl.get_parameter("bundle-dir");

	_do_compile = cl.has_argument("compile");
	if (_do_compile)
	{
		_platform = cl.get_parameter("platform");
		if (_platform == NULL)
		{
			help("Platform must be specified.");
			return EXIT_FAILURE;
		}
		else if (true
			&& strcmp("android", _platform) != 0
			&& strcmp("linux", _platform) != 0
			&& strcmp("windows", _platform) != 0
			)
		{
			help("Unknown platform.");
			return EXIT_FAILURE;
		}

		_source_dir = cl.get_parameter("source-dir");
		if (_source_dir == NULL)
		{
			help("Source dir must be specified.");
			return EXIT_FAILURE;
		}

		_bundle_dir = cl.get_parameter("bundle-dir");
		if (_bundle_dir == NULL)
		{
			help("Bundle dir must be specified.");
			return EXIT_FAILURE;
		}
	}

	if (_bundle_dir != NULL)
	{
		if (!path::is_absolute(_bundle_dir))
		{
			help("Bundle dir must be absolute.");
			return EXIT_FAILURE;
		}
	}

	if (_source_dir != NULL)
	{
		if (!path::is_absolute(_source_dir))
		{
			help("Source dir must be absolute.");
			return EXIT_FAILURE;
		}
	}

	_do_continue = cl.has_argument("continue");

	_boot_dir = cl.get_parameter("boot-dir");
	if (_boot_dir != NULL)
	{
		if (!path::is_relative(_boot_dir))
		{
			help("Boot dir must be relative.");
			return EXIT_FAILURE;
		}
	}

	_wait_console = cl.has_argument("wait-console");

	const char* parent = cl.get_parameter("parent-window");
	if (parent != NULL)
	{
		if (sscanf(parent, "%u", &_parent_window) != 1)
		{
			help("Parent window is invalid.");
			return EXIT_FAILURE;
		}
	}

	const char* port = cl.get_parameter("console-port");
	if (port != NULL)
	{
		if (sscanf(port, "%hu", &_console_port) != 1)
		{
			help("Console port is invalid.");
			return EXIT_FAILURE;
		}
	}

	return EXIT_SUCCESS;
}
Пример #6
0
//-----------------------------------------------------------------------------
void Device::unpause()
{
	_is_paused = false;
	CE_LOGI("Engine unpaused.");
}
Пример #7
0
//-----------------------------------------------------------------------------
void Device::pause()
{
	_is_paused = true;
	CE_LOGI("Engine paused.");
}