1--       _________ __                 __
2--      /   _____//  |_____________ _/  |______     ____  __ __  ______
3--      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
4--      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
5--     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
6--             \/                  \/          \//_____/            \/
7--  ______________________                           ______________________
8--                        T H E   W A R   B E G I N S
9--         Stratagus - A free fantasy real time strategy game engine
10--
11--      ui.lua - Define the human user interface
12--
13--      (c) Copyright 2001-2012 by Lutz Sammer, Kyran Jackson, and Jimmy Salmon
14--
15--      This program is free software; you can redistribute it and/or modify
16--      it under the terms of the GNU General Public License as published by
17--      the Free Software Foundation; either version 2 of the License, or
18--      (at your option) any later version.
19--
20--      This program is distributed in the hope that it will be useful,
21--      but WITHOUT ANY WARRANTY; without even the implied warranty of
22--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23--      GNU General Public License for more details.
24--
25--      You should have received a copy of the GNU General Public License
26--      along with this program; if not, write to the Free Software
27--      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28--
29
30DefineCursor({
31  Name = "cursor-point",
32  Race = "human",
33  File = "ui/human/cursors/human_gauntlet.png",
34  HotSpot = { 3,  2},
35  Size = {28, 32}})
36DefineCursor({
37  Name = "cursor-green-hair",
38  Race = "human",
39  File = "ui/human/cursors/green_eagle.png",
40  HotSpot = {15, 15},
41  Size = {32, 32}})
42DefineCursor({
43  Name = "cursor-yellow-hair",
44  Race = "human",
45  File = "ui/human/cursors/yellow_eagle.png",
46  HotSpot = {15, 15},
47  Size = {32, 32}})
48DefineCursor({
49  Name = "cursor-red-hair",
50  Race = "human",
51  File = "ui/human/cursors/red_eagle.png",
52  HotSpot = {15, 15},
53  Size = {32, 32}})
54
55--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56--	* Mythic/Freeman race
57--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
58
59wargus.playlist = { "music/Human Battle 1" .. wargus.music_extension, "music/Human Battle 2" .. wargus.music_extension,
60	"music/Human Battle 3" .. wargus.music_extension, "music/Human Battle 4" .. wargus.music_extension, "music/Human Battle 5" .. wargus.music_extension}
61
62if (wargus.bne == true) then
63	table.insert(wargus.playlist, "music/Human Battle 6" .. wargus.music_extension)
64end
65
66function HumanScreen(screen_width, screen_height)
67  local info_panel_x = 0
68  local info_panel_y = Video.Height - 136 - 24 - 16
69
70  local ui = {
71    "info-panel", {
72      "panels", {"panel-general-contents", "panel-attack-unit-contents",
73                "panel-all-unit-contents", "panel-building-contents"},
74      "completed-bar", {
75        "color", {48, 100, 4}
76      }
77    }
78  }
79end
80
81UI.NormalFontColor = "white"
82UI.ReverseFontColor = "white"
83
84UI.Fillers:clear()
85
86b = CFiller:new_local()
87b.G = CGraphic:New("ui/human/infopanel.png", 176, 176)
88b.X = 0
89b.Y = Video.Height - 136 - 24 - 16
90UI.Fillers:push_back(b)
91
92function AddFiller(file, x, y)
93	if CanAccessFile(file) == true then
94		b = CFiller:new_local()
95		b.G = CGraphic:New(file)
96		b.X = x
97		b.Y = y
98		UI.Fillers:push_back(b)
99	end
100end
101
102AddFiller("ui/human/filler1.png", 176 + 176 + 176, Video.Height - 136 - 24)
103AddFiller("ui/human/resource.png", 0, 0)
104AddFiller("ui/human/buttonpanel.png", 176 + 176, Video.Height - 160)
105AddFiller("ui/human/menubutton.png", 176, Video.Height - 136 - 24)
106AddFiller("ui/human/minimap.png", 176, Video.Height - 136)
107AddFiller("ui/human/statusline.png", 176, Video.Height - 160 - 16)
108
109UI.InfoPanel.X = 0
110UI.InfoPanel.Y = Video.Height - 136 - 24 - 16
111
112b = CUIButton:new()
113b.X = 9
114b.Y = Video.Height - 136 - 24 - 16 + 9
115b.Style = FindButtonStyle("icon")
116UI.SingleSelectedButton = b
117
118UI.SelectedButtons:clear()
119
120function AddSelectedButton(x, y)
121	b = CUIButton:new_local()
122	b.X = x
123	b.Y = y + (Video.Height - 160 - 160 - 16) -- Terrible hack
124	b.Style = FindButtonStyle("icon")
125	UI.SelectedButtons:push_back(b)
126end
127
128AddSelectedButton(9, 160 + 9)
129AddSelectedButton(65, 160 + 9)
130AddSelectedButton(121, 160 + 9)
131AddSelectedButton(9, 160 + 63)
132AddSelectedButton(65, 160 + 63)
133AddSelectedButton(121, 160 + 63)
134AddSelectedButton(9, 160 + 117)
135AddSelectedButton(65, 160 + 117)
136AddSelectedButton(121, 160 + 117)
137
138UI.MaxSelectedFont = Fonts["game"]
139UI.MaxSelectedTextX = 10
140UI.MaxSelectedTextY = 160 + 10
141
142b = CUIButton:new()
143b.X = 110
144b.Y = 160 + 11 + 70 + (Video.Height - 160 - 160 - 16) -- Terrible hack
145b.Style = FindButtonStyle("icon")
146UI.SingleTrainingButton = b
147
148UI.TrainingButtons:clear()
149
150function AddTrainingButton(x, y)
151	b = CUIButton:new_local()
152	b.X = x
153	b.Y = y + (Video.Height - 160 - 160 - 16) -- Terrible hack
154	b.Style = FindButtonStyle("icon")
155	UI.TrainingButtons:push_back(b)
156end
157
158AddTrainingButton(9, 219)
159AddTrainingButton(65, 219)
160AddTrainingButton(121, 219)
161AddTrainingButton(9, 266)
162AddTrainingButton(65, 266)
163AddTrainingButton(121, 266)
164
165b = CUIButton:new()
166b.X = 110
167b.Y = 160 + 11 + 70 + (Video.Height - 160 - 160 - 16) -- Terrible hack
168b.Style = FindButtonStyle("icon")
169UI.UpgradingButton = b
170
171b = CUIButton:new()
172b.X = 110
173b.Y = 160 + 11 + 70 + (Video.Height - 160 - 160 - 16) -- Terrible hack
174b.Style = FindButtonStyle("icon")
175UI.ResearchingButton = b
176
177UI.TransportingButtons:clear()
178
179function AddTransportingButton(x, y)
180	b = CUIButton:new_local()
181	b.X = x
182	b.Y = y + (Video.Height - 160 - 160 - 16) -- Terrible hack
183	b.Style = FindButtonStyle("icon")
184	UI.TransportingButtons:push_back(b)
185end
186
187AddTransportingButton(9, 387)
188AddTransportingButton(65, 387)
189AddTransportingButton(121, 387)
190AddTransportingButton(9, 434)
191AddTransportingButton(65, 434)
192AddTransportingButton(121, 434)
193
194UI.CompletedBarColorRGB = CColor(48, 100, 4)
195UI.CompletedBarShadow = true
196
197UI.ButtonPanel.Buttons:clear()
198
199function AddButtonPanelButton(x, y)
200	b = CUIButton:new_local()
201	b.X = x + (176 + 176) -- Terrible hack
202	b.Y = y + (Video.Height - 160 - 160 - 160) -- Terrible hack
203	b.Style = FindButtonStyle("icon")
204	UI.ButtonPanel.Buttons:push_back(b)
205end
206
207AddButtonPanelButton(9, 340)
208AddButtonPanelButton(65, 340)
209AddButtonPanelButton(121, 340)
210AddButtonPanelButton(9, 387)
211AddButtonPanelButton(65, 387)
212AddButtonPanelButton(121, 387)
213AddButtonPanelButton(9, 434)
214AddButtonPanelButton(65, 434)
215AddButtonPanelButton(121, 434)
216
217UI.ButtonPanel.X = 0
218UI.ButtonPanel.Y = 336
219UI.ButtonPanel.AutoCastBorderColorRGB = CColor(0, 0, 252)
220
221UI.MapArea.X = 0
222UI.MapArea.Y = 16
223UI.MapArea.EndX = Video.Width - 2
224UI.MapArea.EndY = Video.Height - 136 - 24 - 16
225
226UI.Minimap.X = 176 + 24
227UI.Minimap.Y = Video.Height - 136 + 2
228UI.Minimap.W = 128
229UI.Minimap.H = 128
230
231UI.StatusLine.TextX = 2 + 176
232UI.StatusLine.TextY = Video.Height + 2 - 16 - 160
233UI.StatusLine.Width = Video.Width - 16 - 2 - 176
234UI.StatusLine.Font = Fonts["game"]
235
236-- gold
237UI.Resources[1].G = CGraphic:New("ui/gold,wood,oil,mana.png", 14, 14)
238UI.Resources[1].IconFrame = 0
239UI.Resources[1].IconX = 176 + 0
240UI.Resources[1].IconY = 0
241UI.Resources[1].TextX = 176 + 0 + 18
242UI.Resources[1].TextY = 1
243
244-- wood
245UI.Resources[2].G = CGraphic:New("ui/gold,wood,oil,mana.png", 14, 14)
246UI.Resources[2].IconFrame = 1
247UI.Resources[2].IconX = 176 + 75
248UI.Resources[2].IconY = 0
249UI.Resources[2].TextX = 176 + 75 + 18
250UI.Resources[2].TextY = 1
251
252-- oil
253UI.Resources[3].G = CGraphic:New("ui/gold,wood,oil,mana.png", 14, 14)
254UI.Resources[3].IconFrame = 2
255UI.Resources[3].IconX = 176 + 150
256UI.Resources[3].IconY = 0
257UI.Resources[3].TextX = 176 + 150 + 18
258UI.Resources[3].TextY = 1
259
260-- food
261UI.Resources[FoodCost].G = CGraphic:New("ui/food.png", 14, 14)
262UI.Resources[FoodCost].IconFrame = 0
263UI.Resources[FoodCost].IconX = Video.Width - 16 - 138
264UI.Resources[FoodCost].IconY = 0
265UI.Resources[FoodCost].TextX = Video.Width - 16 - 138 + 18
266UI.Resources[FoodCost].TextY = 1
267
268-- score
269UI.Resources[ScoreCost].G = CGraphic:New("ui/score.png", 14, 14)
270UI.Resources[ScoreCost].IconFrame = 0
271UI.Resources[ScoreCost].IconX = Video.Width - 16 - 68
272UI.Resources[ScoreCost].IconY = 0
273UI.Resources[ScoreCost].TextX = Video.Width - 16 - 68 + 18
274UI.Resources[ScoreCost].TextY = 1
275
276-- mana
277UI.Resources[ManaResCost].G = CGraphic:New("graphics/ui/gold,wood,oil,mana.png", 14, 14)
278UI.Resources[ManaResCost].IconFrame = 3
279UI.Resources[ManaResCost].IconX = -100
280UI.Resources[ManaResCost].IconY = -100
281UI.Resources[ManaResCost].TextX = -100
282UI.Resources[ManaResCost].TextY = -100
283
284UI.MenuButton.X = 176 + 24
285UI.MenuButton.Y = UI.MapArea.EndY + 2 + 16
286UI.MenuButton.Text = _("Menu (~<F10~>)")
287UI.MenuButton.Style = FindButtonStyle("main")
288UI.MenuButton:SetCallback(
289  function()
290    if (Editor.Running == EditorNotRunning) then
291	  RunGameMenu()
292	else
293	  RunInEditorMenu()
294	end
295  end)
296
297UI.NetworkMenuButton.X = 6
298UI.NetworkMenuButton.Y = 2
299UI.NetworkMenuButton.Text = _("Menu")
300UI.NetworkMenuButton.Style = FindButtonStyle("network")
301UI.NetworkMenuButton:SetCallback(function() RunGameMenu() end)
302
303UI.NetworkDiplomacyButton.X = 90
304UI.NetworkDiplomacyButton.Y = 2
305UI.NetworkDiplomacyButton.Text = _("Diplomacy")
306UI.NetworkDiplomacyButton.Style = FindButtonStyle("network")
307UI.NetworkDiplomacyButton:SetCallback(function() RunDiplomacyMenu() end)
308
309