Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 6a4f97a58427fe18e2a8a4632f7a4da3cbc1c87d (plain)
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
/*
   client/mainmenu.cc
   This file is part of the Osirion project and is distributed under
   the terms and conditions of the GNU General Public License version 2
*/

#include "client/mainmenu.h"
#include "ui/paint.h"
#include "ui/ui.h"

namespace client
{

MainMenu::MainMenu(ui::Widget *parent) : ui::Window(parent)
{
	// default main menus 
	mainmenu_mainmenu  = 0;
	mainmenu_gamemenu  = 0;
	mainmenu_joinmenu  = 0;
	
	// default extra menus
	mainmenu_optionsmenu = 0;
	mainmenu_loadmenu = 0;
	mainmenu_savemenu = 0;
	mainmenu_connectmenu = 0;
	
	set_background(true);
	set_label("mainmenu");
}

MainMenu::~MainMenu()
{
}

void MainMenu::show()
{
	ui::Widget::show();
}

void MainMenu::hide()
{
	ui::Widget::hide();
}

void MainMenu::resize()
{
	// resize and reposition all child windows
	const float smallmargin = ui::UI::elementsize.height();
	for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); ++child) {
		(*child)->set_size(width() -  smallmargin * 2, height() -  smallmargin * 4);
		(*child)->set_location(smallmargin, smallmargin * 2);
	}
}

void MainMenu::draw_background()
{
	// we override draw_background instead of adding a ui::Bitmap child
	// this simplifies child window managment
	if (mainmenu_background.size()) {
		ui::Paint::draw_bitmap(global_location(), size(), math::Color(), mainmenu_background);
	}
}

} // namespace client