-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.lua
182 lines (100 loc) · 2.83 KB
/
help.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; print('hello from top of Help module.')
require("button")
require("cmn")
require("common")
require("globals")
require("layout")
require("love")
require("menu-main")
require("nback")
require("tiledbackground")
local pallete = require("pallete")
local fonts = require("fonts")
local i18n = require("i18n")
Help = {Desc = {}, }
local Help_mt = {
__index = Help,
}
function Help.new()
local self = {
font = fonts.help.font,
}
return setmetatable(self, Help_mt)
end
local g = love.graphics
function Help:init()
self:buildLayout()
self:buildButtons()
self.ui = storeUI()
self:prepareDrawDescription()
end
function Help:buildButtons()
local mainMenuBtnLayout = shrink(self.layout.top, nback.border)
self.mainMenuBtn = Button.new(i18n("help.backButton"),
mainMenuBtnLayout.x, mainMenuBtnLayout.y,
mainMenuBtnLayout.w, mainMenuBtnLayout.h)
self.mainMenuBtn.font = fonts.help.gooi
self.mainMenuBtn.bgColor = { 0.208, 0.220, 0.222 }
end
function Help:buildLayout()
self.layout = {}
self.layout.top, self.layout.bottom = splith(makeScreenTable(), 0.1, 0.9)
end
function Help:resize(_, _)
self:buildLayout()
end
function Help:enter()
print("help:enter()")
restoreUI(self.ui)
end
function Help:leave()
print("help:leave()")
self.ui = storeUI()
end
function Help:prepareDrawDescription()
self.desc = {}
local w, h = g.getDimensions()
local x, y = math.floor(self.layout.bottom.x), math.floor(self.layout.bottom.y)
local descText = i18n("help.desc")
descText = descText or ""
self.desc.x, self.desc.y = x, y
self.desc.canvas = g.newCanvas(w, h)
g.setCanvas(self.desc.canvas)
g.setColor({ 1, 1, 1, 1 })
g.clear(pallete.background)
g.setFont(self.font)
g.printf(descText, x, y, w - 100, "center")
g.setCanvas()
end
function Help:drawDescription()
g.setColor({ 1, 1, 1 })
g.draw(self.desc.canvas, self.desc.x, self.desc.y)
end
function Help:draw()
g.clear(pallete.background)
tiledback:draw(0.3)
self:drawDescription()
self.mainMenuBtn:draw()
end
function Help:update(dt)
self.mainMenuBtn:update(dt)
end
function Help:mousepressed(_, _, _, _)
print("help:mousepressed()")
if self.mainMenuBtn.mousePressed then
self.mainMenuBtn:mousePressed()
end
end
function Help:mousereleased(_, _, _, _)
print("help:mousereleased()")
if self.mainMenuBtn.mouseReleased then
self.mainMenuBtn:mouseReleased()
end
end
function Help:keypressed(key)
if key == "escape" then
mainMenu:goBack()
end
end
help = Help.new()
print('hello from bottom of Help module.')