1
include "scripting/richtext.lua"
4
-- .. _richtext_scenarios.lua:
6
-- richtext_scenarios.lua
7
-- ----------------------
9
-- Functions to simplify text formatting in scenarios and make it consistent.
10
-- Most of these functions are simple wrapper functions for our :ref:`richtext system <wlrichtext>`.
11
-- This file will include :ref:`richtext.lua` for you for additional formatting functions.
6
14
-- .. function:: speech(img, clr, title, text)
21
24
-- :arg img: name of the image to use for this speaker
22
25
-- :arg clr: a valid 6 char hex color to use for the name of this speaker
26
-- :arg title: Title of this text. Use empty string if you don't want any.
27
-- :arg text: The text itself.
23
28
-- :returns: the formatted text.
25
function speech(img, clr, g_title, g_text)
26
local title, text = g_title, g_text
30
function speech(img, clr, title, text)
32
title = h1(clr, title)
32
35
-- Surround the text with translatable ","
33
36
text = (_'“%s”'):format(text)
37
s = rt("<p font-size=20 font-weight=bold font-face=serif " ..
38
("font-color=%s>"):format(clr) .. title ..
39
"</p><p font-size=8> <br></p>"
43
return s .. rt(("image=%s"):format(img), p(text))
38
return title .. li_image(img, p(text))
43
-- .. function:: paragraphdivider()
45
-- Closes a paragraph and opens a new paragraph. Use this when you format a string with the speech function
46
-- and need to divide the speech into multiple paragraphs.
48
-- :returns: close_p() .. open_p()
50
function paragraphdivider()
51
return close_p() .. open_p()
55
60
-- :returns: a rich text object that contains the formatted
58
63
function objective_text(heading, body)
59
return rt(h2(heading) .. p(body))
64
return h2(heading) .. p(body)
69
-- .. function:: new_objectives(...)
71
-- Append an objective text with a header to a dialog box in a nice fashion.
72
-- For displaying objectives with an extra title when an advisor is talking
65
74
-- Provides nice formatting for objective texts.
75
-- The following arguments will be parsed:
77
-- - number: the number of objectives described in the body
78
-- - body: the objective text, e.g. created with function objective_text(heading, body)
67
80
-- :returns: a rich text object that contains the formatted
68
81
-- objective text & title.
70
83
function new_objectives(...)
73
86
for idx,obj in ipairs{...} do
87
text = text .. obj.body
75
88
sum = sum + obj.number
77
return rt("<p font-size=10> <br></p>" ..
78
"<p font=serif font-size=18 font-weight=bold font-color=D1D1D1>"
79
.. ngettext("New Objective", "New Objectives", sum) .. "</p>") .. s
90
return h1(ngettext("New Objective", "New Objectives", sum)) .. text