Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tutorial hint messages persistent #6620

Merged
merged 6 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion data/campaigns/tutorial/_main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
[/units]

[lua]
code="wesnoth.require 'campaigns/tutorial/lua/character_selection.lua'"
code=<<
wesnoth.require 'campaigns/tutorial/lua/character_selection'
wesnoth.require 'campaigns/tutorial/lua/hint_message'
>>
[/lua]

{campaigns/tutorial/utils}
Expand Down
30 changes: 30 additions & 0 deletions data/campaigns/tutorial/lua/hint_message.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

local hint_message = {valid = false}
local hint_text = ""
function wesnoth.wml_actions.hint_message(cfg)
if hint_message.valid then
hint_message:remove()
end
if cfg.message and not cfg.remove then
hint_text = cfg.message
if cfg.caption and cfg.caption ~= "" then
hint_text = "<b><big>" .. cfg.caption .. "</big></b>\n" .. hint_text
end
hint_message = wesnoth.interface.add_overlay_text(hint_text, {
size = 18,
location = {5,5},
color = {255, 255, 255},
duration = "unlimited",
max_width = "40%",
valign = "top",
halign = "left"
})
end
end

wesnoth.persistent_tags.hint_message.read = wesnoth.wml_actions.hint_message

function wesnoth.persistent_tags.hint_message.write(add)
add{message = hint_text}
end

102 changes: 34 additions & 68 deletions data/campaigns/tutorial/scenarios/01_Tutorial_part_1.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,15 @@
{CLEAR_PRINT}

{GENDER (
[message]
speaker=narrator
[hint_message]
caption= _ "Movement"
image=wesnoth-icon.png
message= _ "When you hover over or select a unit, in this case Konrad, the places he can move to are highlighted. All units have a certain number of <i>movement points</i>, which dictate how many hexes that unit can move per turn. Normally, moving one hex on flat terrain uses one movement point. To move, simply click on Konrad and then your destination. (You can press <b>u</b> to undo a move if you move to the wrong place.)" +
{CONTINUE_MSG}
[/message]
message= _ "When you hover over or select a unit, in this case Konrad, the places he can move to are highlighted. All units have a certain number of <i>movement points</i>, which dictate how many hexes that unit can move per turn. Normally, moving one hex on flat terrain uses one movement point. To move, simply click on Konrad and then your destination. (You can press <b>u</b> to undo a move if you move to the wrong place.)"
[/hint_message]
) (
[message]
speaker=narrator
[hint_message]
caption= _ "Movement"
image=wesnoth-icon.png
message= _ "When you hover over or select a unit, in this case Li’sar, the places she can move to are highlighted. All units have a certain number of <i>movement points</i>, which dictate how many hexes that unit can move per turn. Normally, moving one hex on flat terrain uses one movement point. To move, simply click on Li’sar and then your destination. (You can press <b>u</b> to undo a move if you move to the wrong place.)" +
{CONTINUE_MSG}
[/message]
message= _ "When you hover over or select a unit, in this case Li’sar, the places she can move to are highlighted. All units have a certain number of <i>movement points</i>, which dictate how many hexes that unit can move per turn. Normally, moving one hex on flat terrain uses one movement point. To move, simply click on Li’sar and then your destination. (You can press <b>u</b> to undo a move if you move to the wrong place.)"
[/hint_message]
)}

# [message]speaker=narrator deselects the unit, so reselect it now
Expand Down Expand Up @@ -508,19 +502,15 @@
)}

{GENDER (
[message]
speaker=narrator
[hint_message]
caption= _"Attacking"
image=wesnoth-icon.png
message= _ "To attack the quintain, first select the attacker (Konrad), then the target (the quintain). You will see an attack description. Click <b>Attack</b> when you’re ready."
[/message]
[/hint_message]
) (
[message]
speaker=narrator
[hint_message]
caption= _"Attacking"
image=wesnoth-icon.png
message= _"To attack the quintain, first select the attacker (Li’sar), then the target (the quintain). You will see an attack description. Click <b>Attack</b> when you’re ready."
[/message]
[/hint_message]
)}

[disallow_end_turn]
Expand Down Expand Up @@ -558,19 +548,15 @@
[/message]

{GENDER (
[message]
speaker=narrator
[hint_message]
caption= _ "Crowns"
image=wesnoth-icon.png
message= _ "The tiny golden crown above your leader (Konrad) indicates he is a side leader. In most scenarios, you will lose if your leader is killed. Be sure to keep him safe!"
[/message]
[/hint_message]
) (
[message]
speaker=narrator
[hint_message]
caption= _ "Crowns"
image=wesnoth-icon.png
message= _ "The tiny golden crown above your leader (Li’sar) indicates she is a side leader. In most scenarios, you will lose if your leader is killed. Be sure to keep her safe!"
[/message]
[/hint_message]
)}

# Check where Delfador is, to set the remaining moves accordingly
Expand Down Expand Up @@ -611,12 +597,10 @@

[allow_end_turn][/allow_end_turn]

[message]
speaker=narrator
[hint_message]
caption= _ "Turns"
image=wesnoth-icon.png
message= _ "Every turn, each side in a scenario gets a chance to make their move. Once you’ve completed everything you wish to do this turn, click on the <b>End Turn</b> button in the bottom right of the screen. The other sides, whether controlled by the AI or other human players, will then make their move. Some scenarios must be completed in a certain number of turns. You can see what turn it is, and any applicable turn limit, next to the flag icon at the top of the screen."
[/message]
[/hint_message]

{PRINT (_"End your turn")}
[/event]
Expand Down Expand Up @@ -689,12 +673,10 @@

{CLEAR_PRINT}

[message]
speaker=narrator
[hint_message]
caption= _ "Villages"
image=wesnoth-icon.png
message= _"You have captured a village! It now flies your colors and has been added to your total village count (the house icon at the top of the screen shows how many villages you currently control). Villages provide the gold needed to recruit units. Each turn, you gain 2 gold, plus 1 for every village you own."
[/message]
[/hint_message]

[allow_end_turn][/allow_end_turn]

Expand Down Expand Up @@ -770,12 +752,10 @@
side=1
[/set_recruit]

[message]
speaker=narrator
[hint_message]
caption= _ "Recruiting"
image=wesnoth-icon.png
message= _ "Whenever you’re on a <i>keep</i>, you can <i>recruit</i> units on the castle tiles around it by right-clicking and selecting <b>Recruit</b>. Note that newly recruited units cannot act the turn you recruit them; you will be able to use them next turn. For this scenario, you have only one type of unit to choose from: the Elvish Fighter."
[/message]
[/hint_message]

{PRINT (_"Recruit two Elvish Fighters")}
[/event]
Expand All @@ -794,12 +774,10 @@

{CLEAR_PRINT}

[message]
speaker=narrator
[hint_message]
caption= _ "Traits"
image=wesnoth-icon.png
message= _"Be sure to examine the <i>traits</i> of your new recruits. They are listed under its race in the sidebar. Traits can subtly affect how you use your troops. For example, units with the <i>quick</i> trait can move an extra hex each turn, and units with the <i>intelligent</i> trait require 20% less experience to level up."
[/message]
[/hint_message]

# Allow our hero to move freely until next turn without undo messages now that the recruiting is done
{VARIABLE enable_undo_messages no}
Expand Down Expand Up @@ -1009,36 +987,30 @@
[/show_if]
[/message]

[message]
speaker=narrator
[hint_message]
caption= _ "Unit Descriptions"
image=wesnoth-icon.png
message= _ "You can right-click on a unit to see a detailed <b>Unit Description</b>."
[/message]
[/hint_message]
[/event]

# TURN 7: protect your troops
[event]
name=turn 7

[message]
speaker=narrator
[hint_message]
caption= _ "Protect Your Troops"
image=wesnoth-icon.png
message= _ "Remember to pull back wounded units into villages and recruit more if needed. Take special care of units with the highest <i>experience points (XP)</i> so they can gain levels and become more powerful."
[/message]
[/hint_message]
[/event]

# TURN 8: support
[event]
name=turn 8

[message]
speaker=narrator
[hint_message]
caption= _ "Support"
image=wesnoth-icon.png
message= _"Each village you control will <i>support</i> one unit for free. After that, each unit costs you one gold per turn."
[/message]
[/hint_message]
[/event]

# TURN 9: advancement
Expand All @@ -1055,25 +1027,21 @@
[/show_if]
[/message]

[message]
speaker=narrator
[hint_message]
caption= _ "Advancement"
image=wesnoth-icon.png
message= _ "When a unit gains enough experience points (the <i>experience bar</i>, if present, is on the <b>right</b> of the <i>hitpoints bar</i>), it will gain a level. Elvish Fighters have two advancement options, and you will be able to choose which one you want. However, second level units cost twice as much to support as first level units."
[/message]
[/hint_message]
[/event]

# TURN 10: defenses
[event]
name=turn 10

[message]
speaker=narrator
[hint_message]
caption= _ "Defenses"
image=wesnoth-icon.png
# wmllint: local spelling quintains
message= _ "Whenever one of your units is selected, you’ll see varying percentages as you move the mouse over the map. The higher the percentage, the more <i>defense</i> that unit has in that kind of terrain. For example, most units have good defenses in castles and villages but poor defenses in rivers. Some units, like these quintains, have a <i>magical</i> attack, which always has a 70% chance of hitting no matter what terrain their targets occupy."
[/message]
[/hint_message]
[/event]

[event]
Expand Down Expand Up @@ -1239,12 +1207,10 @@
[event]
name=victory

[message]
speaker=narrator
[hint_message]
caption= _ "Victory"
image=wesnoth-icon.png
message= _ "After your victory notice, the map will be grayed out to indicate that the scenario is over; this is called <i>linger mode</i>. You will still be able to examine the final positions and state of your troops and any surviving enemies. When you’re finished, click the <b>End Scenario</b> button to go on to the next scenario in the campaign."
[/message]
[/hint_message]
[/event]

[event]
Expand Down