MainGameCallback *g_gamecallback = NULL;
-// Instance of the time getter
-static TimeGetter *g_timegetter = NULL;
-
-u32 getTimeMs()
-{
- if (g_timegetter == NULL)
- return 0;
- return g_timegetter->getTime(PRECISION_MILLI);
-}
-
-u32 getTime(TimePrecision prec) {
- if (g_timegetter == NULL)
- return 0;
- return g_timegetter->getTime(prec);
-}
-
ClientLauncher::~ClientLauncher()
{
if (receiver)
return false;
}
- // Create time getter
- g_timegetter = new IrrlichtTimeGetter(device);
-
// Speed tests (done after irrlicht is loaded to get timer)
if (cmd_args.getFlag("speedtests")) {
dstream << "Running speed tests" << std::endl;
porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C);
- porting::setXorgWindowIcon(device);
+ porting::setWindowIcon(device);
/*
This changes the minimum allowed number of vertices in a VBO.
device->setResizable(true);
- if (random_input)
- input = new RandomInputHandler();
- else
- input = new RealInputHandler(device, receiver);
+ init_input();
smgr = device->getSceneManager();
smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
return device != NULL;
}
+void ClientLauncher::init_input()
+{
+ if (random_input)
+ input = new RandomInputHandler();
+ else
+ input = new RealInputHandler(device, receiver);
+
+ if (g_settings->getBool("enable_joysticks")) {
+ irr::core::array<irr::SJoystickInfo> infos;
+ std::vector<irr::SJoystickInfo> joystick_infos;
+
+ // Make sure this is called maximum once per
+ // irrlicht device, otherwise it will give you
+ // multiple events for the same joystick.
+ if (device->activateJoysticks(infos)) {
+ infostream << "Joystick support enabled" << std::endl;
+ joystick_infos.reserve(infos.size());
+ for (u32 i = 0; i < infos.size(); i++) {
+ joystick_infos.push_back(infos[i]);
+ }
+ input->joystick.onJoystickConnect(joystick_infos);
+ } else {
+ errorstream << "Could not activate joystick support." << std::endl;
+ }
+ }
+}
+
bool ClientLauncher::launch_game(std::string &error_message,
bool reconnect_requested, GameParams &game_params,
const Settings &cmd_args)
device = createDeviceEx(params);
- if (device) {
- if (g_settings->getBool("enable_joysticks")) {
- irr::core::array<irr::SJoystickInfo> infos;
- std::vector<irr::SJoystickInfo> joystick_infos;
- // Make sure this is called maximum once per
- // irrlicht device, otherwise it will give you
- // multiple events for the same joystick.
- if (device->activateJoysticks(infos)) {
- infostream << "Joystick support enabled" << std::endl;
- joystick_infos.reserve(infos.size());
- for (u32 i = 0; i < infos.size(); i++) {
- joystick_infos.push_back(infos[i]);
- }
- } else {
- errorstream << "Could not activate joystick support." << std::endl;
- }
- }
+ if (device)
porting::initIrrlicht(device);
- }
return device != NULL;
}