Add tutorial texts for Touch interface
authorWuzzy <Wuzzy2@mail.ru>
Sat, 08 Dec 2018 14:33:49 +0100
changeset 14382 f9d4b8222903
parent 14381 32e8c81ca35c
child 14383 cea19d3342c8
Add tutorial texts for Touch interface
share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua	Sat Dec 08 14:22:24 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua	Sat Dec 08 14:33:49 2018 +0100
@@ -130,23 +130,42 @@
 end
 
 function newGamePhase()
+	local ctrl = ""
 	-- Spawn targets, update wind and ammo, show instructions
 	if gamePhase == 0 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Open ammo menu: [Right click]").."|"..
+			loc("Select weapon: [Left click]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Open ammo menu: Tap the [suitcase]")
+		end
 		ShowMission(loc("Basic Bazooka Training"), loc("Select Weapon"), loc("To begin with the training, select the bazooka from the ammo menu!").."|"..
-		loc("Open ammo menu: [Right click]").."|"..
-		loc("Select weapon: [Left click]"), 2, 5000)
+		ctrl, 2, 5000)
 	elseif gamePhase == 1 then
-		ShowMission(loc("Basic Bazooka Training"), loc("My First Bazooka"), loc("Let's get started!").."|"..
+		if INTERFACE == "desktop" then
+			ctrl = loc("Attack: [Space]").."|"..
+			loc("Aim: [Up]/[Down]").."|"..
+			loc("Walk: [Left]/[Right]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Attack: Tap the [bomb]").."|"..
+			loc("Aim: [Up]/[Down]").."|"..
+			loc("Walk: [Left]/[Right]")
+		end
+		ShowMission(loc("Basic Bazooka Training"), loc("My First Bazooka"),
+		loc("Let's get started!").."|"..
 		loc("Launch some bazookas to destroy the targets!").."|"..
 		loc("Hold the Attack key pressed for more power.").."|"..
 		loc("Don't hit yourself!").."|"..
-		loc("Attack: [Space]").."|"..
-		loc("Aim: [Up]/[Down]").."|"..
-		loc("Walk: [Left]/[Right]"), 2, 10000)
+		ctrl, 2, 10000)
 		spawnTargets()
 	elseif gamePhase == 2 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("You see the wind strength at the bottom right corner.")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("You see the wind strength at the top.")
+		end
 		ShowMission(loc("Basic Bazooka Training"), loc("Wind"), loc("Bazookas are influenced by wind.").."|"..
-		loc("You see the wind strength at the bottom right corner.").."|"..
+		ctrl.."|"..
 		loc("Destroy the targets!"), 2, 5000)
 		SetWind(50)
 		spawnTargets()
@@ -181,9 +200,12 @@
 		SetWind(-33)
 		spawnTargets()
 	elseif gamePhase == 6 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Precise Aim: [Left Shift] + [Up]/[Down]").."|"
+		end
 		ShowMission(loc("Basic Bazooka Training"), loc("Final Targets"),
 		loc("The final targets are quite tricky. You need to aim well.").."|"..
-		loc("Precise Aim: [Left Shift] + [Up]/[Down]").."|"..
+		ctrl..
 		loc("Hint: It might be easier if you vary the angle only slightly."),
 		2, 12000)
 		SetWind(75)
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua	Sat Dec 08 14:22:24 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua	Sat Dec 08 14:33:49 2018 +0100
@@ -96,10 +96,14 @@
 		AddGear(945, 498, gtTarget, 0, 0, 0, 0)
 	-- Bounciness
 	elseif gamePhase == 4 then
-		AddGear(323, 960, gtTarget, 0, 0, 0, 0)
 		AddGear(1318, 208, gtTarget, 0, 0, 0, 0)
 		AddGear(1697, 250, gtTarget, 0, 0, 0, 0)
-		AddGear(1852, 100, gtTarget, 0, 0, 0, 0)
+		if INTERFACE ~= "touch" then
+			-- These targets may be too hard in touch interface because you cannot set bounciness yet
+			-- FIXME: Allow these targets in touch when bounciness can be set
+			AddGear(323, 960, gtTarget, 0, 0, 0, 0)
+			AddGear(1852, 100, gtTarget, 0, 0, 0, 0)
+		end
 	-- Grand Final
 	elseif gamePhase == 5 then
 		AddGear(186, 473, gtTarget, 0, 0, 0, 0)
@@ -117,24 +121,42 @@
 
 function newGamePhase()
 	-- Spawn targets, update wind and ammo, show instructions
+	local ctrl = ""
 	if gamePhase == 0 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Open ammo menu: [Right click]").."|"..
+			loc("Select weapon: [Left click]")
+		else
+			ctrl = loc("Open ammo menu: Tap the [suitcase]")
+		end
 		ShowMission(loc("Basic Grenade Training"), loc("Select Weapon"), loc("To begin with the training, select the grenade from the ammo menu!").."|"..
-		loc("Open ammo menu: [Right click]").."|"..
-		loc("Select weapon: [Left click]"), 2, 5000)
+		ctrl, 2, 5000)
 	elseif gamePhase == 1 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Attack: [Space]").."|"..
+			loc("Aim: [Up]/[Down]").."|"..
+			loc("Change direction: [Left]/[Right]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Attack: Tap the [bomb]").."|"..
+			loc("Aim: [Up]/[Down]").."|"..
+			loc("Change direction: [Left]/[Right]")
+		end
 		ShowMission(loc("Basic Grenade Training"), loc("Warming Up"),
 		loc("Throw a grenade to destroy the target!").."|"..
 		loc("Hold the Attack key pressed for more power.").."|"..
-		loc("Attack: [Space]").."|"..
-		loc("Aim: [Up]/[Down]").."|"..
-		loc("Change direction: [Left]/[Right]").."|"..
+		ctrl.."|"..
 		loc("Note: Walking is disabled in this mission."), 2, 20000)
 		spawnTargets()
 	elseif gamePhase == 2 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Set detonation timer: [1]-[5]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Change detonation timer: Tap the [clock]")
+		end
 		ShowMission(loc("Basic Grenade Training"), loc("Timer"),
 		loc("You can change the detonation timer of grenades.").."|"..
 		loc("Grenades explode after 1 to 5 seconds (you decide).").."|"..
-		loc("Set detonation timer: [1]-[5]"), 2, 15000)
+		ctrl, 2, 15000)
 		spawnTargets()
 	elseif gamePhase == 3 then
 		ShowMission(loc("Basic Grenade Training"), loc("No Wind Influence"), loc("Unlike bazookas, grenades are not influenced by wind.").."|"..
@@ -142,17 +164,28 @@
 		SetWind(50)
 		spawnTargets()
 	elseif gamePhase == 4 then
-		ShowMission(loc("Basic Grenade Training"), loc("Bounciness"),
-		loc("You can set the bounciness of grenades (and grenade-like weapons).").."|"..
-		loc("Grenades with high bounciness bounce a lot and behave chaotic.").."|"..
-		loc("With low bounciness, it barely bounces at all, but it is much more predictable.").."|"..
-		loc("Try out different bounciness levels to reach difficult targets.").."|"..
-		loc("Set bounciness: [Left Shift] + [1]-[5]"),
-		2, 20000)
+		local caption = loc("Bounciness")
+		if INTERFACE == "desktop" then
+			ctrl = loc("You can set the bounciness of grenades (and grenade-like weapons).").."|"..
+			loc("Grenades with high bounciness bounce a lot and behave chaotic.").."|"..
+			loc("With low bounciness, it barely bounces at all, but it is much more predictable.").."|"..
+			loc("Try out different bounciness levels to reach difficult targets.").."|"..
+			loc("Set bounciness: [Left Shift] + [1]-[5]")
+		elseif INTERFACE == "touch" then
+			-- FIXME: Bounciness can't be set in touch yet. :(
+			caption = loc("Well done!")
+			ctrl = loc("You're getting pretty good! Here are more targets for you.")
+		end
+
+		ShowMission(loc("Basic Grenade Training"), caption, ctrl, 2, 20000)
 		spawnTargets()
 	elseif gamePhase == 5 then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Precise Aim: [Left Shift] + [Up]/[Down]")
+			-- FIXME: No precise aim in touch interface yet :(
+		end
 		ShowMission(loc("Basic Grenade Training"), loc("Final Targets"), loc("Good job! Now destroy the final targets to finish the training.").."|"..
-		loc("Precise Aim: [Left Shift] + [Up]/[Down]"),
+		ctrl,
 		2, 7000)
 		spawnTargets()
 	elseif gamePhase == 6 then
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua	Sat Dec 08 14:22:24 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua	Sat Dec 08 14:33:49 2018 +0100
@@ -241,7 +241,10 @@
 	crates[7] = SpawnHealthCrate(1198, 1750)		-- Back Jumping 2
 	crates[8] = SpawnSupplyCrate(1851, 1402, amSwitch, 100)	-- Switch Hedgehog
 	crates[9] = SpawnHealthCrate(564, 1772)			-- Health
-	crates[10] = SpawnHealthCrate(2290, 1622)		-- Turning Around
+	-- FIXME: Not available in touch because no “precise” button
+	if INTERFACE ~= "touch" then
+		crates[10] = SpawnHealthCrate(2290, 1622)		-- Turning Around
+	end
 end
 
 local function victory()
@@ -265,11 +268,17 @@
 		loc("To finish hedgehog selection, just do anything|with him, like walking."),
 		2, 20000)
 	else
+		local ctrl = ""
+		if INTERFACE == "desktop" then
+			ctrl = loc("Hit the “Switch Hedgehog” key until you have|selected Cappy, the hedgehog with the cap!").."|"..
+			loc("Switch hedgehog: [Tabulator]")
+		else
+			ctrl = loc("Tap the “rotating arrow” button on the left|until you have selected Cappy, the hedgehog with the cap!")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Switch Hedgehog (2/3)"),
 		loc("You have activated Switch Hedgehog!").."|"..
 		loc("The spinning arrows above your hedgehog show|which hedgehog is selected right now.").."|"..
-		loc("Hit the “Switch Hedgehog” key until you have|selected Cappy, the hedgehog with the cap!").."|"..
-		loc("Switch hedgehog: [Tabulator]"), 2, 20000)
+		ctrl, 2, 20000)
 	end
 end
 
@@ -281,6 +290,7 @@
 end
 
 function onGearDelete(gear)
+	local ctrl = ""
 	-- Switching done
 	if GetGearType(gear) == gtSwitcher then
 		switcherGear = nil
@@ -290,57 +300,99 @@
 			loc("Collect the remaining crates to complete the training."),
 			2, 0)
 		else
+			if INTERFACE == "desktop" then
+				ctrl = loc("Open ammo menu: [Right click]").."|"..
+				loc("Attack: [Space]")
+			elseif INTERFACE == "touch" then
+				ctrl = loc("Open ammo menu: Tap the [suitcase]").."|"..
+				loc("Attack: Tap the [bomb]")
+			end
 			ShowMission(loc("Basic Movement Training"), loc("Switch Hedgehog (Failed!)"),
 			loc("Oops! You have selected the wrong hedgehog! Just try again.").."|"..
 			loc("Select “Switch Hedgehog” from the ammo menu and|hit the “Attack” key to proceed.").."|"..
-			loc("Open ammo menu: [Right click]").."|"..
-			loc("Attack: [Space]"), 2, 0)
+			ctrl, 2, 0)
 		end
 
 	-- Crate collected (or destroyed, but this should not be possible)
 	elseif gear == crates[1] then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Long Jump: [Enter]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Long Jump: Tap the [curvy arrow] for long")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Jumping"),
 		loc("Get the next crate by jumping over the abyss.").."|"..
 		loc("Careful, hedgehogs can't swim!").."|"..
-		loc("Long Jump: [Enter]"), 2, 5000)
+		ctrl, 2, 5000)
 	elseif gear == crates[2] then
 		victory()
 	elseif gear == crates[4] then
+		if INTERFACE == "desktop" then
+			ctrl = loc("High Jump: [Backspace]").."|"..loc("Back Jump: [Backspace] ×2")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("High Jump: Tap the [curvy arrow] shortly").."|"..loc("Back Jump: Double-tap the [curvy arrow]")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Back Jumping (1/2)"),
 		loc("For the next crate, you have to do back jumps.") .. "|" ..
 		loc("To reach higher ground, walk to a ledge, look to the left, then do a back jump.") .. "|" ..
-		loc("High Jump: [Backspace]").."|"..loc("Back Jump: [Backspace] ×2"), 2, 6600)
+		ctrl, 2, 6600)
 	elseif gear == crates[7] then
+		if INTERFACE == "desktop" then
+			ctrl = loc("High Jump: [Backspace]").."|"..loc("Back Jump: [Backspace] ×2")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("High Jump: Tap the [curvy arrow] short").."|"..loc("Back Jump: Double-tap the [curvy arrow]")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Back Jumping (2/2)"),
 		loc("To get over the next obstacles, keep some distance from the wall before you back jump.").."|"..
 		loc("Hint: To jump higher, wait a bit before you hit “High Jump” a second time.").."|"..
-		loc("High Jump: [Backspace]").."|"..loc("Back Jump: [Backspace] ×2"), 2, 15000)
+		ctrl, 2, 15000)
 	elseif gear == crates[5] then
+		-- FIXME: Touch doesn't have precise aim yet :(
+		if INTERFACE == "desktop" then
+			ctrl = "|" ..
+			loc("You can also hold down the key for “Precise Aim” to prevent slipping.") .. "|" ..
+			loc("Precise Aim: [Left Shift]")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Walking on Ice"),
 		loc("These girders are slippery, like ice.").."|"..
 		loc("And you need to move to the top!").."|"..
-		loc("If you don't want to slip away, you have to keep moving!").."|"..
-		loc("You can also hold down the key for “Precise Aim” to prevent slipping.").."|"..
-		loc("Precise Aim: [Left Shift]"), 2, 9000)
+		loc("If you don't want to slip away, you have to keep moving!")..
+		ctrl, 2, 9000)
 	elseif gear == crates[6] then
+		-- FIXME: Touch doesn't have precise aim yet :(
+		if INTERFACE == "desktop" then
+			ctrl = "|" .. loc("Remember: Hold down [Left Shift] to prevent slipping")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("A mysterious Box"),
-		loc("The next crate is an utility crate.").."|"..loc("What's in the box, you ask? Let's find out!").."|"..
-		loc("Remember: Hold down [Left Shift] to prevent slipping"), 2, 6000)
+		loc("The next crate is an utility crate.").."|"..loc("What's in the box, you ask? Let's find out!")..
+		ctrl, 2, 6000)
 	elseif gear == crates[8] then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Open ammo menu: [Right click]").."|"..
+			loc("Attack: [Space]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Open ammo menu: Tap the [suitcase]").."|"..
+			loc("Attack: Tap the [bomb]")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Switch Hedgehog (1/3)"),
 		loc("You have collected the “Switch Hedgehog” utility!").."|"..
 		loc("This allows to select any hedgehog in your team!").."|"..
 		loc("Select “Switch Hedgehog” from the ammo menu and|hit the “Attack” key.").."|"..
-		loc("Open ammo menu: [Right click]").."|"..
-		loc("Attack: [Space]"), 2, 30000)
+		ctrl, 2, 30000)
 	elseif gear == crates[3] then
 		ShowMission(loc("Basic Movement Training"), loc("Rubber"), loc("As you probably noticed, these rubber bands|are VERY elastic. Hedgehogs and many other|things will bounce off without taking any damage.").."|"..
 		loc("Now try to get out of this bounce house|and take the next crate."), 2, 8000)
 	elseif gear == crates[9] then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Look around: [Mouse movement]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Look around: [Tap or swipe on the screen]")
+		end
 		ShowMission(loc("Basic Movement Training"), loc("Health"), loc("You just got yourself some extra health.|The more health your hedgehogs have, the better!").."|"..
 		loc("Now go to the next crate.").."|"..
-		loc("Look around: [Mouse movement]"), 2, 10000)
+		ctrl, 2, 10000)
 	elseif gear == crates[10] then
+		-- FIXME: This crate is unused in touch atm
 		ShowMission(loc("Basic Movement Training"), loc("Turning Around"),
 		loc("By the way, you can turn around without walking|by holding down Precise when you hit a walk control.").."|"..
 		loc("Get the final crate to the right to complete the training.").."|"..
@@ -369,17 +421,26 @@
 	-- This part is CRITICALLY important for all future missions.
 	-- Because the player must know how to show the current mission texts again.
 	-- We force the player to hit Attack before the actual training begins.
+	local ctrl = ""
+	if INTERFACE == "desktop" then
+		ctrl = loc("IMPORTANT: To see the mission panel again, hold the mission panel key.").."| |"..
+		loc("Note: This basic training assumes default controls.").."|"..
+		loc("Mission panel: [M]").."|"..
+		loc("Quit: [Esc]").."|"..
+		loc("Pause: [P]").."| |"..
+		loc("To begin with the training, hit the attack key!").."|"..
+		loc("Attack: [Space]")
+	elseif INTERFACE == "touch" then
+		ctrl = loc("IMPORTANT: To see the mission panel again, pause the game.").."| |"..
+		loc("Pause: Tap the [pause symbol]").."| |"..
+		loc("To begin with the training, tap the attack button!").."|"..
+		loc("Attack: Tap the [bomb]")
+	end
 	ShowMission(loc("Basic Movement Training"), loc("Mission Panel"),
 	loc("This is the mission panel.").."|"..
 	loc("Here you will find the current mission instructions.").."|"..
 	loc("Normally, the mission panel disappears after a few seconds.").."|"..
-	loc("IMPORTANT: To see the mission panel again, hold the mission panel key.").."| |"..
-	loc("Note: This basic training assumes default controls.").."|"..
-        loc("Mission panel: [M]").."|"..
-	loc("Quit: [Esc]").."|"..
-	loc("Pause: [P]").."| |"..
-	loc("To begin with the training, hit the attack key!").."|"..
-	loc("Attack: [Space]"), 2, 900000, true)
+	ctrl, 2, 900000, true)
 
 	-- TODO: This and other training missions are currently hardcoding control names.
 	-- This should be fixed eventually.
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Sat Dec 08 14:22:24 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Sat Dec 08 14:33:49 2018 +0100
@@ -194,10 +194,16 @@
 end
 
 function onNewTurn()
+	local ctrl = ""
 	if not wasFirstTurn then
+		if INTERFACE == "desktop" then
+			ctrl = loc("Open ammo menu: [Right click]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Open ammo menu: Tap the [suitcase]")
+		end
 		ShowMission(loc("Basic Rope Training"), loc("Select Rope"),
 		loc("Select the rope to begin!").."|"..
-		loc("Open ammo menu: [Right click]"), 2, 7500)
+		ctrl, 2, 7500)
 		wasFirstTurn = true
 	end
 	if isInMineChallenge then
@@ -212,11 +218,18 @@
 
 	-- First rope selection
 	if not ropeSelected and GetCurAmmoType() == amRope then
+		local ctrl = ""
+		if INTERFACE == "desktop" then
+			ctrl = loc("Aim: [Up]/[Down]").."|"..
+			loc("Attack: [Space]")
+		elseif INTERFACE == "touch" then
+			ctrl = loc("Aim: [Up]/[Down]").."|"..
+			loc("Attack: Tap the [bomb]")
+		end
 		ShowMission(loc("Basic Rope Training"), loc("Getting Started"),
 		loc("You can use the rope to reach new places.").."|"..
 		loc("Aim at the ceiling and hold [Attack] pressed until the rope attaches.").."|"..
-		loc("Aim: [Up]/[Down]").."|"..
-		loc("Attack: [Space]"), 2, 15000)
+		ctrl, 2, 15000)
 		ropeSelected = true
 	-- Rope attach
 	elseif ropeGear and band(GetState(ropeGear), gstCollision) ~= 0 then
@@ -367,11 +380,18 @@
 	elseif GetGearType(gear) == gtRope then
 		ropeGear = nil
 		if ropeAttached and not target1Reached then
+			local ctrl = ""
+			if INTERFACE == "desktop" then
+				ctrl = loc("Aim: [Up]/[Down]").."|"..
+				loc("Attack: [Space]")
+			elseif INTERFACE == "touch" then
+				ctrl = loc("Aim: [Up]/[Down]").."|"..
+				loc("Attack: Tap the [bomb]")
+			end
 			ShowMission(loc("Basic Rope Training"), loc("How to Rope"),
 			loc("Go to the target.").."|"..
 			loc("Hold [Attack] to attach the rope.").."|"..
-			loc("Aim: [Up]/[Down]").."|"..
-			loc("Attack: [Space]"), 2, 13000)
+			ctrl, 2, 13000)
 			ropeAttached = false
 		end
 	elseif GetGearType(gear) == gtMine then