------------------------------------------------Load tweak file------------------------------------------------

require( "config/game_tweak.cfg" );

function InitNewGame()
	local Callback = "F_tuto_start";
	if( G_force_tutorial == 0 ) then
		Callback = "F_Tuto_Intro";
	end
	NewGameProcedures()
	SetFaeryPositionScreen( G_tutorial_fairy_default_position_x, G_tutorial_fairy_default_position_y, G_tutorial_fairy_speed, Callback );
end

function InitNewStartGame()
	NewGameProcedures()
	SetFaeryPositionScreen( G_tutorial_fairy_default_position_x, G_tutorial_fairy_default_position_y, G_tutorial_fairy_speed, "F_Tuto_Intro" );
end

function NewGameProcedures()
	PlaySound( "sounds/ambiance/ambiance_riviere.ogg", true, FXSound, "LD_fixed_mill" );
	
	DisableInput(true);
	DisableMapNavigation(true);
	SetFaeryWait(true);
	
	SetSpiritImmunization(true);
	DisableAIForAllCharacters(true);
	DisableAIForLabrador(true);
	
	
	SetButtonHUDActivated(false);
	SetFeeButtonActivated(false);
	SetMapButtonActivated(false);
	SetTomeButtonActivated(false);
	SetShopButtonActivated(false);
	--SetSpeedButtonActivated(false);
	SetChienButtonActivated(false);	
	
	SetCollectionEnabled(false);
end

function InitLoadGame()
	--F_immediate_dialogbox("load_title", "load_text")
    DoModal("scripts/away_report.lua");
	--EventTriggerAfterLoading()
end

function InitLevel()
  if( IsQuestElementCompleted( "Q_beeflower_fixing" ) ) then
	PlayFX(Fogs, "fx/abeilles.lua", "Bee_00", 0, 0);
  end
  if( IsQuestElementCompleted( "Q_mushroom_fixing" ) ) then
	PlayFX(Fogs, "fx/lucioles.lua", "LD_mushroom_light_trans", 0, 0);
  end
  
  if( IsFirstClickable( "LD_ruins_stele_exploration" ) and not IsFirstClicked( "Q_world_history_ruins_exploring" ) ) then
	PlayFX(Air, "fx/fx_boutique_4.lua", "LD_ruins_stele_exploration", 0, 0);
  end
  if( IsFirstClickable( "LD_firefly_tree_fruit" ) and not IsFirstClicked( "Q_firefly_kingdom_fruit_feeding" ) ) then
	PlayFX(Air, "fx/fx_boutique_4.lua", "Luciole", 0, 0);
  end
  if( IsFirstClickable( "Sage" ) and not IsFirstClicked( "Q_swamp_sage_lookingafter" ) ) then
	PlayFX(Air, "fx/fx_boutique_4.lua", "Sage", 0, 0);
  end
  if( IsFirstClickable( "LD_watering_can" ) and not IsFirstClicked( "Q_swamp_watering_can_fixing" ) ) then
	PlayFX(Air, "fx/fx_boutique_4.lua", "LD_watering_can", 0, 0)
  end
  if( IsFirstClickable( "LD_alambic" ) and not IsFirstClicked( "Q_alambic_fixing" ) ) then
	PlayFX(Air, "fx/fx_boutique_4.lua", "LD_alambic", 0, 0)
  end
  if( IsFirstClickable( "LD_honey_spoon" ) and not IsFirstClicked( "Q_honey_spoon_fixing" ) ) then
	PlayFX(Air, "fx/fx_boutique_4.lua", "LD_honey_spoon", 0, 0)
  end
end

-- fDt : delta time between two frames

function F_quit_ig()
    local bodyquit = "";
	local IsInLinearTuto = false;
	if( IsGameInLinearTuto() ) then
		bodyquit = "quitigtutoconfirm";
		IsInLinearTuto = true;
	else
		bodyquit = "quitigconfirm";
	end
		result = DisplayDialog {
			"scripts/yesno.lua",
			body = bodyquit,
			title = "quitigtitle"
		};
	if(result == 'yes') then
	    if ( IsInLinearTuto == false ) then
			LogGameEvent( "Game_Quit", Time_to_time_event );
			Save();
		else
			LogGameEvent( "Game_Quit_Before_TutoEnd", Time_to_time_event );
		end
		PostMessage( CreateNamedMessage( kQuitNow, "quit" ) );
	end
end

function F_labrador_bark_highlight()
	PlaySound( "sounds/animaux/labrador/dog_call_01.ogg", false, FXSound, "id_labrador" );
	HighlightButton( "chien", false );
	return true;
end

function F_labrador_bark()
	PlaySound( "sounds/animaux/labrador/dog_call_01.ogg", false, FXSound, "id_labrador" );
	return true;
end

function F_labrador_bark_stop()
	if( IsSoundPlaying( "sounds/animaux/labrador/dog_call_01.ogg", FXSound, "id_labrador" ) ) then
		KillSound( "sounds/animaux/labrador/dog_call_01.ogg", FXSound, "id_labrador" );
	end
	return true;
end

function F_FaeryHouseAnim_End()
	DeferDelete( "T_FaeryHouseTimer" );
	gTempFunction = 
		function()
			DoModal("scripts/faeriehouse.lua");
		end;
	table.insert( gCommandQueue,gTempFunction );
	return true;
end

function F_play_music_begin( sOwnerName )
PlayMusicFX( sOwnerName );
PlayFX( Characters, "fx/aura_musicien.lua", sOwnerName, 0, 0 );
return true
end

function F_play_music_stop( sOwnerName )
KillMusicFX( sOwnerName );
KillFX( Characters, "fx/aura_musicien.lua", sOwnerName );
KillMusicSound( sOwnerName )
return true
end
