void BinderRace::bindAllFunctions()
 {
   bindFunction( LuaInterface::raceGetName,           "raceGetName");
   bindFunction( LuaInterface::raceGetWorker,         "raceGetWorker");
   bindFunction( LuaInterface::raceGetCenter,         "raceGetCenter");
   bindFunction( LuaInterface::raceGetRefinery,       "raceGetRefinery");
   bindFunction( LuaInterface::raceGetTransport,      "raceGetTransport");
   bindFunction( LuaInterface::raceGetSupplyProvider, "raceGetSupplyProvider");
 }
Exemple #2
0
Map::Map () :
		IMap(), _frontend(nullptr), _serviceProvider(nullptr), _forcedFinish(false), _autoSolve(false), _nextSolveStep(0)
{
	Commands.registerCommand(CMD_MAP_PAUSE, bindFunction(Map, triggerPause));
	Commands.registerCommand(CMD_MAP_RESTART, bindFunction(Map, triggerRestart));
	Commands.registerCommand(CMD_START, bindFunction(Map, startMap));
	Commands.registerCommand(CMD_FINISHMAP, bindFunction(Map, finishMap));
	Commands.registerCommand("map_print", bindFunction(Map, printMap));
	Commands.registerCommand("solve", bindFunction(Map, solveMap));

	resetCurrentMap();
}
Exemple #3
0
Map::Map () :
		IMap(), _world(nullptr), _frontend(nullptr), _serviceProvider(nullptr), _theme(&ThemeTypes::ROCK)
{
	Commands.registerCommand(CMD_MAP_PAUSE, bindFunction(Map, triggerPause));
	Commands.registerCommand(CMD_MAP_RESTART, bindFunction(Map, triggerRestart));
	Commands.registerCommand(CMD_MAP_DEBUG, bindFunction(Map, triggerDebug));
	Commands.registerCommand(CMD_START, bindFunction(Map, startMap));
	Commands.registerCommand(CMD_KILL, bindFunction(Map, killPlayers));
	Commands.registerCommand(CMD_FINISHMAP, bindFunction(Map, finishMap));

	resetCurrentMap();
}
GooglePlayPersister::GooglePlayPersister(IGameStatePersister* delegate) :
		IGameStatePersister(), _delegate(delegate)
#ifdef GOOGLEPLAY_ACTIVE
		,
		_env(nullptr), _cls(nullptr), _loadGameState(nullptr), _saveGameState(nullptr),
		_persisterInit(nullptr), _persisterConnect(nullptr), _persisterDisconnect(nullptr),
		_showLeaderBoard(nullptr), _showAchievements(nullptr), _addPointsToLeaderBoard(nullptr)
#endif
{
	Commands.registerCommand("googleplay-connect", bindFunction(GooglePlayPersister, connect));
	Commands.registerCommand("googleplay-disconnect", bindFunction(GooglePlayPersister, disconnect));
	Commands.registerCommand("googleplay-upload", bindFunction(GooglePlayPersister, upload));
	Commands.registerCommand("googleplay-download", bindFunction(GooglePlayPersister, download));
	Commands.registerCommand("googleplay-showachievements", bindFunction(GooglePlayPersister, showAchievements));
	Commands.registerCommand("googleplay-showleaderboard", bindFunction(GooglePlayPersister, showLeaderBoard));
}
Exemple #5
0
void UI::init (ServiceProvider& serviceProvider, EventHandler &eventHandler, IFrontend &frontend)
{
	System.track("step", "initui");
	const std::string& language = Config.getLanguage();
	if (!initLanguage(language))
		initLanguage("en_GB");
	Commands.registerCommand(CMD_UI_PRINTSTACK, bindFunction(UI, printStack));
	Commands.registerCommand(CMD_UI_PUSH, bindFunction(UI, pushCmd));
	Commands.registerCommand(CMD_UI_RESTART, bindFunction(UI, initRestart));
	Commands.registerCommand(CMD_UI_POP, bindFunction(UI, pop));
	Commands.registerCommand(CMD_UI_FOCUS_NEXT, bindFunction(UI, focusNext));
	Commands.registerCommand(CMD_UI_FOCUS_PREV, bindFunction(UI, focusPrev));
	Commands.registerCommand(CMD_UI_EXECUTE, bindFunction(UI, runFocusNode));
	_showCursor = Config.getConfigVar("showcursor", System.wantCursor() ? "true" : "false", true)->getBoolValue();
	_cursor = _showCursor;
	if (_cursor)
		info(LOG_CLIENT, "enable cursor");
	else
		info(LOG_CLIENT, "disable cursor");

	_serviceProvider = &serviceProvider;
	_eventHandler = &eventHandler;
	_frontend = &frontend;
	eventHandler.registerObserver(this);

	info(LOG_CLIENT, "init the texture cache with " + serviceProvider.getTextureDefinition().getTextureSize());
	_textureCache.init(_frontend, serviceProvider.getTextureDefinition());
	_spriteCache.init();

	FontDefinition& fontDef = Singleton<FontDefinition>::getInstance();
	FontDefMapConstIter i = fontDef.begin();
	for (; i != fontDef.end(); ++i) {
		_fonts[i->second->id] = BitmapFontPtr(new BitmapFont(i->second, _frontend));
	}

	Singleton<GameRegistry>::getInstance().getGame()->initUI(_frontend, serviceProvider);

	_mouseCursor = loadTexture("mouse");

	loadGesture(zoominGesture, SDL_arraysize(zoominGesture));
	loadGesture(zoomoutGesture, SDL_arraysize(zoomoutGesture));
}
 void BinderUnitType::bindAllFunctions()
 {
   bindFunction( LuaInterface::unitTypeGetName,             "unitTypeGetName");
   bindFunction( LuaInterface::unitTypeGetSubLabel,         "unitTypeGetSubLabel");
   bindFunction( LuaInterface::unitTypeGetRace,             "unitTypeGetRace");
   bindFunction( LuaInterface::unitTypeWhatBuilds,          "unitTypeWhatBuilds");
   bindFunction( LuaInterface::unitTypeRequiredUnits,       "unitTypeRequiredUnits");
   bindFunction( LuaInterface::unitTypeRequiredTech,        "unitTypeRequiredTech");
   bindFunction( LuaInterface::unitTypeAbilities,           "unitTypeAbilities");
   bindFunction( LuaInterface::unitTypeUpgrades,            "unitTypeUpgrades");
   bindFunction( LuaInterface::unitTypeArmorUpgrade,        "unitTypeArmorUpgrade");
   bindFunction( LuaInterface::unitTypeMaxHitPoints,        "unitTypeMaxHitPoints");
   bindFunction( LuaInterface::unitTypeMaxShields,          "unitTypeMaxShields");
   bindFunction( LuaInterface::unitTypeMaxEnergy,           "unitTypeMaxEnergy");
   bindFunction( LuaInterface::unitTypeArmor,               "unitTypeArmor");
   bindFunction( LuaInterface::unitTypeMineralPrice,        "unitTypeMineralPrice");
   bindFunction( LuaInterface::unitTypeGasPrice,            "unitTypeGasPrice");
   bindFunction( LuaInterface::unitTypeBuildTime,           "unitTypeBuildTime");
   bindFunction( LuaInterface::unitTypeSupplyRequired,      "unitTypeSupplyRequired");
   bindFunction( LuaInterface::unitTypeSupplyProvided,      "unitTypeSupplyProvided");
   bindFunction( LuaInterface::unitTypeSpaceProvided,       "unitTypeSpaceProvided");
   bindFunction( LuaInterface::unitTypeBuildScore,          "unitTypeBuildScore");
   bindFunction( LuaInterface::unitTypeDestroyScore,        "unitTypeDestroyScore");
   bindFunction( LuaInterface::unitTypeSize,                "unitTypeSize");
   bindFunction( LuaInterface::unitTypeTileWidth,           "unitTypeTileWidth");
   bindFunction( LuaInterface::unitTypeTileHeight,          "unitTypeTileHeight");
   bindFunction( LuaInterface::unitTypeDimensionLeft,       "unitTypeDimensionLeft");
   bindFunction( LuaInterface::unitTypeDimensionUp,         "unitTypeDimensionUp");
   bindFunction( LuaInterface::unitTypeDimensionRight,      "unitTypeDimensionRight");
   bindFunction( LuaInterface::unitTypeDimensionDown,       "unitTypeDimensionDown");
   bindFunction( LuaInterface::unitTypeSeekRange,           "unitTypeSeekRange");
   bindFunction( LuaInterface::unitTypeSightRange,          "unitTypeSightRange");
   bindFunction( LuaInterface::unitTypeGroundWeapon,        "unitTypeGroundWeapon");
   bindFunction( LuaInterface::unitTypeMaxGroundHits,       "unitTypeMaxGroundHits");
   bindFunction( LuaInterface::unitTypeAirWeapon,           "unitTypeAirWeapon");
   bindFunction( LuaInterface::unitTypeMaxAirHits,          "unitTypeMaxAirHits");
   bindFunction( LuaInterface::unitTypeTopSpeed,            "unitTypeAcceleration");
   bindFunction( LuaInterface::unitTypeHaltDistance,        "unitType");
   bindFunction( LuaInterface::unitTypeTurnRadius,          "unitTypeTurnRadius");
   bindFunction( LuaInterface::unitTypeCanProduce,          "unitTypeCanProduce");
   bindFunction( LuaInterface::unitTypeCanAttack,           "unitTypeCanAttack");
   bindFunction( LuaInterface::unitTypeCanMove,             "unitTypeCanMove");
   bindFunction( LuaInterface::unitTypeIsFlyer,             "unitTypeIsFlyer");
   bindFunction( LuaInterface::unitTypeRegeneratesHP,       "unitTypeRegeneratesHP");
   bindFunction( LuaInterface::unitTypeIsSpellcaster,       "unitTypeIsSpellcaster");
   bindFunction( LuaInterface::unitTypeHasPermanentCloak,   "unitTypeHasPermanentCloak");
   bindFunction( LuaInterface::unitTypeIsInvincible,        "unitTypeIsInvincible");
   bindFunction( LuaInterface::unitTypeIsOrganic,           "unitTypeIsOrganic");
   bindFunction( LuaInterface::unitTypeIsMechanical,        "unitTypeIsMechanical");
   bindFunction( LuaInterface::unitTypeIsRobotic,           "unitTypeIsRobotic");
   bindFunction( LuaInterface::unitTypeIsDetector,          "unitTypeIsDetector");
   bindFunction( LuaInterface::unitTypeIsResourceContainer, "unitTypeIsResourceContainer");
   bindFunction( LuaInterface::unitTypeIsResourceDepot,     "unitTypeIsResourceDepot");
   bindFunction( LuaInterface::unitTypeIsRefinery,          "unitTypeIsRefinery");
   bindFunction( LuaInterface::unitTypeIsWorker,            "unitTypeIsWorker");
   bindFunction( LuaInterface::unitTypeRequiresPsi,         "unitTypeRequiresPsi");
   bindFunction( LuaInterface::unitTypeRequiresCreep,       "unitTypeRequiresCreep");
   bindFunction( LuaInterface::unitTypeIsTwoUnitsInOneEgg,  "unitTypeIsTwoUnitsInOneEgg");
   bindFunction( LuaInterface::unitTypeIsBurrowable,        "unitTypeIsBurrowable");
   bindFunction( LuaInterface::unitTypeIsCloakable,         "unitTypeIsCloakable");
   bindFunction( LuaInterface::unitTypeIsBuilding,          "unitTypeIsBuilding");
   bindFunction( LuaInterface::unitTypeIsAddon,             "unitTypeIsAddon");
   bindFunction( LuaInterface::unitTypeIsFlyingBuilding,    "unitTypeIsFlyingBuilding");
   bindFunction( LuaInterface::unitTypeIsNeutral,           "unitTypeIsNeutral");
 }
Exemple #7
0
ObjectModule::ObjectModule()
: ScriptModule("Object")
{
	bindFunction(0x0053, game_create_player, 5, "Create Player" );
	
    bindFunction(0x0055, game_set_object_position<PlayerController>, 4, "Set Player Position" );
	bindFunction(0x0056, game_player_in_area_2d, 6, "Is Player In Area 2D" );
	bindFunction(0x0057, game_player_in_area_3d, 8, "Is Player In Area 3D" );
	
	bindFunction(0x009A, game_create_character, 6, "Create Character" );
	bindFunction(0x009B, game_destroy_object<CharacterObject>, 1, "Destroy Character" );
	bindUnimplemented( 0x009C, game_set_character_wander_path, 2, "Set Character Wander Path" );
	
	bindUnimplemented( 0x009F, game_character_make_idle, 1, "Set Character to Idle" );
	
	bindFunction(0x00A1, game_set_object_position<CharacterObject>, 4, "Set Character Position" );
	
	bindFunction(0x00A5, game_create_vehicle, 5, "Create Vehicle" );
	bindFunction(0x00A6, game_destroy_object<VehicleObject>, 1, "Destroy Vehicle" );
	
	bindFunction(0x00AA, game_get_vehicle_position, 4, "Get Vehicle Position" );

	bindUnimplemented( 0x00AF, game_set_vehicle_objective, 2, "Set Vehicle Objective" );
	
	bindFunction(0x00D9, game_get_character_vehicle<CharacterObject>, 2, "Get Character Vehicle" );
	bindFunction(0x00DA, game_get_character_vehicle<PlayerController>, 2, "Get Player Vehicle" );
	bindFunction(0x00DB, game_character_in_vehicle<CharacterObject>, 2, "Is Character in Vehicle" );
	bindFunction(0x00DC, game_character_in_vehicle<PlayerController>, 2, "Is Player in Vehicle" );
	
    bindFunction(0x00DE, game_player_in_model, 2, "Is Player In Model" );
    bindFunction(0x00DF, game_character_in_any_vehicle, 1, "Is Character In Any Vehicle" );
    bindFunction(0x00E0, game_player_in_any_vehicle, 1, "Is Player In Any Vehicle" );
	
	bindFunction(0x00E5, game_player_in_area_2d_in_vehicle, 6, "Is Player in 2D Area in Vehicle" );
	
	bindUnimplemented( 0x00E4, game_locate_character_on_foot_2d, 6, "Locate Player on foot 2D" );

	bindFunction(0x00E6, game_locate_character_stopped_2d<PlayerController>, 6, "Locate Player Stopped 2D" );
	
	bindFunction(0x00E8, game_locate_player_stopped_in_vehicle_2d, 6, "Locate Player Stopped in Vehicle 2D" );
	bindFunction(0x00E9, game_character_near_character_2D, 5, "Locate Character near Character 2D");
	
	bindFunction(0x00EB, game_character_near_character_in_vehicle_2D<PlayerController>, 5, "Is player near character in vehicle" );
	
	bindFunction(0x00ED, game_character_near_point_on_foot_2D, 6, "Is Character near point on foot" );
	
	bindFunction(0x00EF, game_locate_character_stopped_2d<CharacterObject>, 6, "Locate Character Stopped 2D" );

	bindUnimplemented( 0x00F5, game_locate_character_in_sphere, 8, "Locate Player In Sphere" );
    bindFunction(0x00F6, game_player_near_point_on_foot_3D, 8, "Is Player near point on foot" );
    bindFunction(0x00F7, game_player_near_point_in_vehicle_3D, 8, "Is Player near point in car" );
	bindFunction(0x00F9, game_player_stopped_near_point_on_foot_3d, 8, "Detect player stopped on foot area 3d" );

	bindFunction(0x0100, game_character_near_point_in_vehicle, 8, "Is Character near point in car" );
	
	bindFunction(0x0108, game_destroy_object<InstanceObject>, 1, "Destroy Object" );
	
	bindFunction(0x0118, game_character_dead, 1, "Is Character Dead" );
	bindFunction(0x0119, game_vehicle_dead, 1, "Is Vehicle Dead" );
	bindUnimplemented(0x011A, game_set_character_search_threat, 2, "Set Character Search Threat" );
	
	bindUnimplemented(0x011C, game_character_clear_objective, 1, "Clear Character Objective" );
	
	bindFunction(0x0121, game_character_in_zone<PlayerController>, 2, "Is Player In Zone" );
    bindFunction(0x0122, game_player_pressing_horn, 1, "Is Player Pressing Horn" );

    bindFunction(0x0126, game_character_objective_passed, 1, "Character Objective Passed" );
	
	bindFunction(0x0129, game_create_character_in_vehicle, 4, "Create Character In Car" );

	bindUnimplemented(0x0135, game_set_vehicle_locked, 2, "Set Vehicle locked state");

    bindFunction(0x0137, game_is_vehicle_model, 2, "Is Vehicle Model" );
	
	bindFunction(0x0171, game_set_player_heading, 2, "Set Player Heading" );
	
	bindFunction(0x0173, game_set_object_heading<CharacterObject>, 2, "Set Character Heading" );
	bindUnimplemented(0x0174, game_get_character_heading, 2, "Get Vehicle Heading" );
	bindFunction(0x0175, game_set_object_heading<VehicleObject>, 2, "Set Vehicle heading" );
	
	bindFunction(0x0176, game_get_object_heading<InstanceObject>, 2, "Get Object heading" );
	bindFunction(0x0177, game_set_object_heading<InstanceObject>, 2, "Set Object heading" );
	
	bindUnimplemented( 0x0192, game_character_stand_still, 1, "Make character stand still" );
	
	bindFunction(0x0199, game_character_in_area_or_cylinder<PlayerController>, 6, "Is Player in Area or Cylinder" );

	bindFunction(0x019C, game_character_in_area_on_foot<PlayerController>, 8, "Is Player in Area on Foot" );
	bindFunction(0x019E, game_character_stoped_in_volume<PlayerController>, 8, "Is Player stopped in volume" );
	
	bindFunction(0x01A0, game_character_stoped_in_volume_in_vehicle<PlayerController>, 8, "Is Player Stopped in cube in vehicle" );
	bindFunction(0x01A8, game_character_stoped_in_volume<CharacterObject>, 8, "Is Char Stopped in volume" );
	bindFunction(0x01AA, game_character_stoped_in_volume_in_vehicle<CharacterObject>, 8, "Is Char Stopped in cube in vehicle" );

	bindFunction(0x01AD, game_locate_vehicle_near_point_2D, 6, "Locate Vehicle Near Point 2D" );

	bindFunction(0x01B2, game_give_weapon_to_character, 3, "Give Weapon to Character" );

	bindUnimplemented( 0x01BB, game_object_coordinates, 4, "Get Object Coordinates" );
	
	bindUnimplemented( 0x01BE, game_turn_character, 4, "Turn Character To Face Point" );
	
	bindFunction(0x01C1, game_vehicle_stopped, 1, "Is Vehicle Stopped" );
	bindUnimplemented( 0x01C2, game_mark_object_as_unneeded<CharacterObject>, 1, "Mark Character Unneeded" );
	bindUnimplemented( 0x01C3, game_mark_object_as_unneeded<VehicleObject>, 1, "Mark Vehicle Unneeded" );
	
	bindFunction(0x01C7, game_dont_remove_object, 1, "Don't remove object" );
	bindFunction(0x01C8, game_create_character_as_passenger, 5, "Create Character as Passenger" );

	bindUnimplemented( 0x01CC, game_set_character_objective_kill_player_any_means, 2, "Set Character Objective to Kill Player by Any Means" );
	
	bindFunction(0x01D5, game_enter_as_driver, 2, "Character Enter Vehicle as Driver" );
	bindFunction(0x01D4, game_enter_as_passenger, 2, "Character Enter Vehicle as Passenger" );
	bindFunction(0x01D3, game_character_exit_vehicle, 2, "Character Exit Vehicle" );
	
	bindFunction(0x01DF, game_character_follow_character, 2, "Make Character Follow Character");
	
	bindFunction(0x01F3, game_vehicle_in_air, 1, "Is Vehicle In Air" );
	bindFunction(0x01F4, game_vehicle_flipped, 1, "Is Car Flipped" );
	
	bindFunction(0x0204, game_character_near_car_2d, 5, "Is Char near Car in Car 2D" );
	
	bindUnimplemented( 0x020A, game_lock_vehicle_doors, 2, "Lock Car Doors" );
	
	bindFunction(0x0211, game_navigate_on_foot, 3, "Character go to on foot" );
	
	bindFunction(0x0213, game_create_pickup, 6, "Create pickup");
	bindFunction(0x0214, game_is_pickup_collected, 1, "Has Pickup been collected");
	bindFunction(0x0215, game_destroy_pickup, 1, "Destroy Pickup");

	bindFunction(0x0227, game_get_vehicle_health, 2, "Get Vehicle Health" );
	bindFunction(0x0229, game_set_vehicle_colours, 3, "Set Vehicle Colours" );
	
	bindFunction(0x0239, game_character_run_to, 3, "Character Run to" );

	bindUnimplemented( 0x0243, game_set_character_personality, 2, "Set Character Personality" );
	
	bindFunction(0x029B, game_create_object_world, 5, "Create Object no offset" );
	bindFunction(0x029C, game_is_boat, 1, "Is Vehicle Boat" );
	
	bindFunction(0x029F, game_is_character_stopped<PlayerController>, 1, "Is Player Stopped" );

	bindUnimplemented( 0x02AA, game_set_car_only_damageable_by_player, 2, "Set Car Only Damageable by Player" );
	
	bindFunction(0x02B3, game_character_in_area_9<PlayerController>, 9, "Is Player In Area" );

	bindFunction(0x02BF, game_is_vehicle_in_water, 1, "Is Vehicle in Water" );
	
	bindFunction(0x02DE, game_player_in_taxi, 1, "Is Player In Taxi" );
	
	bindFunction(0x02E3, game_get_speed, 2, "Get Vehicle Speed" );

	bindFunction(0x0320, game_character_in_range, 2, "Is Character in range of character");

	bindFunction(0x032B, game_create_weapon_pickup, 7, "Create Weapon Pickup" );

	bindFunction(0x0339, game_objects_in_volume, 11, "Are objects in volume" );
	
	bindFunction( 0x034D, game_rotate_object, 4, "Rotate Object" );
	bindUnimplemented( 0x034E, game_slide_object, 8, "Slide Object" );
	bindFunction(0x034F, game_destroy_object_with_fade<CharacterObject>, 1, "Destroy Character with Fade" );
	
	bindUnimplemented( 0x035D, game_set_object_targetable, 1, "Set Object Targetable" );
	
	bindFunction(0x0363, game_set_close_object_visible, 6, "Set Closest Object Visibility");
	
	bindUnimplemented( 0x0368, game_create_ev_crane, 10, "Create ev Crane" );
	
	bindUnimplemented( 0x039C, game_set_car_watertight, 2, "Set Car Watertight" );

	bindFunction(0x03B6, game_change_nearest_model, 6, "Change Nearest Instance Model" );
	
	bindUnimplemented( 0x03BA, game_clear_area_vehicles, 6, "Clear Cars From Area" );
	
	bindUnimplemented( 0x03BC, game_create_cylinder, 5, "Create Cylinder" ); /// @todo Other sources call this "sphere", this should be our AreaIndicator?
	bindUnimplemented( 0x03BD, game_destroy_cylinder, 1, "Destroy Cylinder" );

	bindFunction(0x03F3, game_get_vehicle_colours, 3, "Get Vehicle Colours" );
	
	bindUnimplemented(0x03F9, game_make_characters_converse, 3, "Make characters converse");
	
	bindUnimplemented( 0x042B, game_clear_volume_pedestrians, 6, "Clear volume pedestrians" );
	
	bindFunction(0x0442, game_character_in_vehicle<PlayerController>, 2, "Is Player in This Vehicle" );
  bindFunction(0x0443, game_player_in_any_vehicle, 1, "Is Player In Any Vehicle" ); /// Duplicate of 00E0?!
	bindFunction(0x0448, game_character_in_vehicle<CharacterObject>, 2, "Is Character in This Vehicle" );
}
void ConfigManager::init (IBindingSpaceListener *bindingSpaceListener, int argc, char **argv)
{
	_persister = new ConfigPersisterSQL();
	Log::info(LOG_CONFIG, "init configmanager");

	_persister->init();

	_bindingSpaceListener = bindingSpaceListener;

	LUA lua;

	Log::info(LOG_CONFIG, "load config lua file");
	const bool success = lua.load("config.lua");
	if (!success) {
		Log::error(LOG_CONFIG, "could not load config");
	}

	if (success) {
		Log::info(LOG_CONFIG, "load config values");
		getKeyValueMap(lua, _configVarMap, "settings");
		Log::info(LOG_CONFIG, "load keybindings");
		getBindingMap(lua, _keybindings, KEY_CONFIG_KEYBINDINGS, KEYBOARD);
		Log::info(LOG_CONFIG, "load controller bindings");
		getBindingMap(lua, _controllerBindings, KEY_CONFIG_CONTROLLERBINDINGS, CONTROLLER);
		Log::info(LOG_CONFIG, "load joystick bindings");
		getBindingMap(lua, _joystickBindings, KEY_CONFIG_JOYSTICKBINDINGS, JOYSTICK);
	}
	_language = getConfigValue(_configVarMap, "language", System.getLanguage());
	_joystick = getConfigValue(_configVarMap, "joystick");
	_showFPS = getConfigValue(_configVarMap, "showfps");
	_width = getConfigValue(_configVarMap, "width", "-1");
	_height = getConfigValue(_configVarMap, "height", "-1");
	_fullscreen = getConfigValue(_configVarMap, "fullscreen", "true");
	_soundEnabled = getConfigValue(_configVarMap, "sound");
	_port = getConfigValue(_configVarMap, "port", "4567");
	_debug = getConfigValue(_configVarMap, "debug", "false");
#ifdef NONETWORK
	_network = getConfigValue(_configVarMap, "network", "false");
#else
	_network = getConfigValue(_configVarMap, "network", "true");
#endif
	_vsync = getConfigValue(_configVarMap, "vsync", "true");
	_textureSize = getConfigValue(_configVarMap, "texturesize", "auto");
	_maxHitpoints = getConfigValue(_configVarMap, "maxhitpoints", "100");
	_damageThreshold = getConfigValue(_configVarMap, "damagethreshold", "0.3");
	_referenceTimeFactor = getConfigValue(_configVarMap, "referencetimefactor", "1.0");
	_fruitCollectDelayForANewLife = getConfigValue(_configVarMap, "fruitcollectdelayforanewlife", "15000");
	_amountOfFruitsForANewLife = getConfigValue(_configVarMap, "amountoffruitsforanewlife", "4");
	_fruitHitpoints = getConfigValue(_configVarMap, "fruithitpoints", "10");
	_npcFlyingSpeed = getConfigValue(_configVarMap, "npcflyingspeed", "4.0");
	_mode = getConfigValue(_configVarMap, "mode", "");
	_waterParticle = getConfigValue(_configVarMap, "waterparticle", "false", CV_READONLY);
	_grabMouse = getConfigValue(_configVarMap, "grabmouse", "true");
	_soundEngine = getConfigValue(_configVarMap, "soundengine", "sdl");
	_particles = getConfigValue(_configVarMap, "particles", "0");
	_serverName = getConfigVar("servername", System.getCurrentUser());
	_name = getConfigVar("name", System.getCurrentUser());
	_amountOfFruitsForANewLife = getConfigValue(_configVarMap, "amountoffruitsforanewlife", "4");
	_debugui = getConfigVar("debugui", "false");
	getConfigVar("debugentity", "false", true);
	getConfigVar("debugui", "false", true);

	for (KeyValueMap::iterator i = _configVarMap.begin(); i != _configVarMap.end(); ++i) {
		getConfigVar(i->first, i->second, true);
	}

	std::vector<std::string> vars;
	_persister->getVars(vars);
	for (std::vector<std::string>::const_iterator i = vars.begin(); i != vars.end(); ++i) {
		getConfigVar(*i);
	}
	for (ConfigVarsMap::iterator i = _configVars.begin(); i != _configVars.end(); ++i) {
		Log::info(LOG_CONFIG, "'%s' with value '%s'", i->first.c_str(), i->second->getValue().c_str());
	}

	memset(&_debugRendererData, 0, sizeof(_debugRendererData));

	Log::info(LOG_CONFIG, "mouse grab enabled: %s", _grabMouse->getValue().c_str());
	Log::info(LOG_CONFIG, "  joystick enabled: %s", _joystick->getValue().c_str());
	Log::info(LOG_CONFIG, "     sound enabled: %s", _soundEnabled->getValue().c_str());
	Log::info(LOG_CONFIG, "     debug enabled: %s", _debug->getValue().c_str());

	CommandSystem::get().registerCommand("loglevel", bindFunction(ConfigManager, setLogLevel));
	CommandSystem::get().registerCommand(CMD_SETVAR, bindFunction(ConfigManager, setConfig));
	CommandSystem::get().registerCommand(CMD_LISTVARS, bindFunction(ConfigManager, listConfigVariables));

	for (int i = 0; i < argc; i++) {
		if (argv[i][0] != '-')
			continue;
		const std::string command = &argv[i][1];
		if (command != CMD_SETVAR)
			continue;
		if (i + 2 >= argc)
			continue;
		const std::string var = argv[i + 1];
		const std::string val = argv[i + 2];
		ConfigVarPtr p = getConfigVar(var);
		p->setValue(val);
		*argv[i] = *argv[i + 1] = *argv[i + 2] = '\0';
		i += 2;
	}
}
void IMapManager::init ()
{
	loadMaps();

	Commands.registerCommand(CMD_LIST_MAPS, bindFunction(IMapManager, listMaps));
}
Exemple #10
0
VMModule::VMModule()
	: ScriptModule("VM")
{
	bindFunction(0x001, vm_sleep, 1, "Sleep thread");
	bindFunction(0x002, vm_jump, 1, "Jump");
	
	bindFunction(0x004, vm_global_int, 2, "Set Global Integer");
	bindFunction(0x005, vm_global_float, 2, "Set Global Float");
	// Local Integers are handled by the VM itself, function can be re-used.
	bindFunction(0x006, vm_global_int, 2, "Set Local Int");
	
	bindFunction(0x008, vm_inc_global_int, 2, "Increment Global Int");
	bindFunction(0x009, vm_inc_global_float, 2, "Increment Global Float");
	bindFunction(0x00C, vm_dec_global_int, 2, "Decrement Global Int");
	bindFunction(0x00D, vm_dec_global_float, 2, "Decrement Global Float");

	bindFunction(0x010, vm_mul_global_int, 2, "Multiply Global Int by Int");

	bindFunction(0x014, vm_div_global_int, 2, "Divide Global by Integer");
	bindFunction(0x015, vm_div_global_float, 2, "Divide Global by Float");

	bindFunction(0x018, vm_global_int_gt_int, 2, "Global Int Greater than Int");
	bindFunction(0x019, vm_global_int_gt_int, 2, "Local Int Greater than Int");

	bindFunction(0x01A, vm_int_gt_global_int, 2, "Int Greater Than Global Int");
	bindFunction(0x01B, vm_int_gt_global_int, 2, "Int Greater Than Var Int");
	
	bindFunction(0x01F, vm_global_int_gt_global_int, 2, "Local Int Greater than Global Int");
	bindFunction(0x020, vm_global_float_gt_float, 2, "Global Float Greather than Float");
	
	bindFunction(0x028, vm_global_int_ge_int, 2, "Global Int >= Int");
	bindFunction(0x029, vm_global_int_ge_int, 2, "Local Int >= Int");
	
	bindFunction(0x02A, vm_int_ge_global_int, 2, "Int >= Global Int");
	
	bindFunction(0x038, vm_global_int_eq_int, 2, "Global Int Equal to Int");
	bindFunction(0x039, vm_global_int_eq_int, 2, "Local Int Equal to Int");
	bindFunction(0x03A, vm_global_int_eq_global_int, 2, "Global Int Equal to Global Int");

	bindFunction(0x042, vm_global_float_eq_float, 2, "Global Float Equal to Float");

	bindFunction(0x04F, vm_new_thread, -1, "Start New Thread");

	bindFunction(0x04D, vm_jump_if_false, 1, "Jump if false");

	bindFunction(0x04E, vm_halt_thread, 0, "End Thread");

	bindFunction(0x050, vm_call, 1, "Gosub");

	bindFunction(0x051, vm_return, 0, "Return");

	bindFunction(0x058, vm_inc_global_int_by_global, 2, "Increment Global Integer by Global Integer");
	bindFunction(0x059, vm_inc_global_float_by_global, 2, "Increment Global Float by Global Float");

	bindFunction(0x060, vm_dec_global_int_by_global, 2, "Decrement Global Integer by Global Integer");
	bindFunction(0x061, vm_dec_global_float_by_global, 2, "Decrement Global Float by Global Float");

	bindFunction(0x069, vm_mul_global_float_by_global, 2, "Multiply Global Float by Global Float");

	bindFunction(0x084, vm_global_int_to_global, 2, "Set Global Int To Global");

	bindFunction(0x086, vm_global_float_to_global, 2, "Set Global Float To Global");

	bindFunction(0x08C, vm_floor_float_to_int, 2, "Floor Float To Int");

	bindFunction(0x0D6, vm_if, 1, "If");

	bindFunction(0x0D7, vm_new_mission_thread, 1, "Start Mission Thread");

	bindFunction(0x0D8, vm_mission_over, 0, "Set Mission Finished");

	bindFunction(0x1FB, vm_sqrt, 2, "Sqrt");

	bindFunction(0x209, vm_random_int_in_range, 3, "Random Int in Range");

	bindFunction(0x2CD, vm_call, 2, "Call");

	bindFunction(0x3A4, vm_name_thread, 1, "Name Thread");

	bindFunction(0x417, vm_start_mission, 1, "Start Mission");
}
void ConfigManager::init (IBindingSpaceListener *bindingSpaceListener, int argc, char **argv)
{
	_persister = new ConfigPersisterSQL(System.getDatabaseDirectory() + Singleton<Application>::getInstance().getName() + ".sqlite");
	Log::info(LOG_COMMON, "init configmanager");

	_persister->init();

	_bindingSpaceListener = bindingSpaceListener;

	LUA lua;

	Log::info(LOG_COMMON, "load config lua file");
	const bool success = lua.load("config.lua");
	if (!success) {
		Log::error(LOG_COMMON, "could not load config");
	}

	if (success) {
		Log::info(LOG_COMMON, "load config values");
		getKeyValueMap(lua, _configVarMap, "settings");
		Log::info(LOG_COMMON, "load keybindings");
		getBindingMap(lua, _keybindings, KEY_CONFIG_KEYBINDINGS, KEYBOARD);
		Log::info(LOG_COMMON, "load controller bindings");
		getBindingMap(lua, _controllerBindings, KEY_CONFIG_CONTROLLERBINDINGS, CONTROLLER);
	}
	_language = getConfigValue(_configVarMap, "language", System.getLanguage());
	_gameController = getConfigValue(_configVarMap, "gamecontroller");
	_gameControllerTriggerAxis = getConfigValue(_configVarMap, "gamecontrollertriggeraxis");
	_showFPS = getConfigValue(_configVarMap, "showfps");
	_width = getConfigValue(_configVarMap, "width", "-1");
	_height = getConfigValue(_configVarMap, "height", "-1");
	_fullscreen = getConfigValue(_configVarMap, "fullscreen", "true");
	_soundEnabled = getConfigValue(_configVarMap, "sound");
	_port = getConfigValue(_configVarMap, "port", "4567");
	_debug = getConfigValue(_configVarMap, "debug", "false");
#ifdef NONETWORK
	_network = getConfigValue(_configVarMap, "network", "false");
#else
	_network = getConfigValue(_configVarMap, "network", "true");
#endif
	_vsync = getConfigValue(_configVarMap, "vsync", "true");
	_textureSize = getConfigValue(_configVarMap, "texturesize", "auto");
	_grabMouse = getConfigValue(_configVarMap, "grabmouse", "true");
	_soundEngine = getConfigValue(_configVarMap, "soundengine", "sdl");
	_particles = getConfigValue(_configVarMap, "particles", "0");
	_renderToTexture = getConfigValue(_configVarMap, "rendertotexture", "1");
	getConfigValue(_configVarMap, "red", "8");
	getConfigValue(_configVarMap, "green", "8");
	getConfigValue(_configVarMap, "blue", "8");
	_serverName = getConfigVar("servername", System.getCurrentUser());
	_name = getConfigVar("name", System.getCurrentUser());
	_debugui = getConfigVar("debugui", "false");
	_debugEntity = getConfigVar("debugentity", "false", true);
	getConfigVar("alreadyrated", "false", true);
	_mode = getConfigValue(_configVarMap, "mode", "");

#if 0
	// disabled because the vars must be created on access - to set the flags properly
	for (KeyValueMap::iterator i = _configVarMap.begin(); i != _configVarMap.end(); ++i) {
		getConfigVar(i->first, i->second, true);
	}

	std::vector<std::string> vars;
	_persister->getVars(vars);
	for (std::vector<std::string>::const_iterator i = vars.begin(); i != vars.end(); ++i) {
		getConfigVar(*i);
	}
	for (auto entry : _configVars) {
		Log::info(LOG_COMMON, "'%s' with value '%s'", entry.first.c_str(), entry.second->getValue().c_str());
	}
#endif

	memset(&_debugRendererData, 0, sizeof(_debugRendererData));

	Log::info(LOG_COMMON, "mouse grab enabled: %s", _grabMouse->getValue().c_str());
	Log::info(LOG_COMMON, "controller enabled: %s", _gameController->getValue().c_str());
	Log::info(LOG_COMMON, "     sound enabled: %s", _soundEnabled->getValue().c_str());
	Log::info(LOG_COMMON, "     debug enabled: %s", _debug->getValue().c_str());

	Commands.registerCommand("loglevel", bindFunction(ConfigManager::setLogLevel));
	CommandPtr cmd = Commands.registerCommand(CMD_SETVAR, bindFunction(ConfigManager::setConfig));
	cmd->setCompleter([&] (const std::string& input, std::vector<std::string>& matches) {
		for (auto entry : _configVars) {
			if (!string::startsWith(entry.first, input))
				continue;
			matches.push_back(entry.first);
		}
	});

	Commands.registerCommand(CMD_LISTVARS, bindFunction(ConfigManager::listConfigVariables));

	for (int i = 0; i < argc; i++) {
		if (argv[i][0] != '-')
			continue;
		const std::string command = &argv[i][1];
		if (command == CMD_SETVAR) {
			if (i + 2 >= argc)
				continue;
			const std::string var = argv[i + 1];
			const std::string val = argv[i + 2];
			ConfigVarPtr p = getConfigVar(var);
			p->setValue(val);
			*argv[i] = *argv[i + 1] = *argv[i + 2] = '\0';
			i += 2;
		} else if (command == "loglevel") {
			if (i + 1 >= argc)
				continue;
			ICommand::Args a;
			a.push_back(argv[i + 1]);
			setLogLevel(a);
			*argv[i] = *argv[i + 1] = '\0';
			i += 1;
		}
	}
	increaseCounter("launchcount");
	_persister->save(_configVars);
}