diff options
Diffstat (limited to 'src/client/mainwindow.cc')
| -rw-r--r-- | src/client/mainwindow.cc | 103 | 
1 files changed, 103 insertions, 0 deletions
| diff --git a/src/client/mainwindow.cc b/src/client/mainwindow.cc new file mode 100644 index 0000000..91cb9b4 --- /dev/null +++ b/src/client/mainwindow.cc @@ -0,0 +1,103 @@ +/* +   client/mainwindow.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 "core/application.h" +#include "client/mainwindow.h" +#include "client/video.h" +#include "ui/ui.h" + +namespace client +{ + +MainWindow::MainWindow(ui::Widget *parent) : ui::Widget(parent) +{ +	set_label("mainwindow"); +	set_border(false); +	set_background(false); + +	// add child widgets +	mainwindow_devinfo = new DevInfoWidget(this); +	mainwindow_statsinfo = new StatsInfoWidget(this); +	mainwindow_keyinfo = new KeyInfoWidget(this); +	mainwindow_clock = new ClockInfoWidget(this); + +	mainwindow_playerview = new PlayerView(this); +	mainwindow_playerview->raise(); +	mainwindow_playerview->hide(); +} + +MainWindow::~MainWindow() +{ + +} + +void MainWindow::resize() +{ +	set_size(parent()->size()); + +	//const float largemargin = ui::UI::elementsize.width() * 0.25 +	const float smallmargin = ui::UI::elementsize.height(); + +	// resize player view +	mainwindow_playerview->set_size(size()); + +	// reposition devinfo widget +	mainwindow_devinfo->set_size(font()->width()*32, font()->height()*5); +	mainwindow_devinfo->set_location(smallmargin, smallmargin); + +	// reposition stats widget +	mainwindow_statsinfo->set_size(font()->width()*12, font()->height()*5); +	mainwindow_statsinfo->set_location(width() - mainwindow_statsinfo->width() - smallmargin, smallmargin); +	 +	// reposition clock +	mainwindow_clock->set_size(font()->width()*7, font()->height()); +	mainwindow_clock->set_location(width() - mainwindow_clock->width() - smallmargin, mainwindow_statsinfo->bottom() + smallmargin); + +	// reposition keypress widget +	mainwindow_keyinfo->set_size(font()->width()*12, font()->height()*1); +	mainwindow_keyinfo->set_location(width() - mainwindow_keyinfo->width() - smallmargin, +				   height() - mainwindow_keyinfo->height() - smallmargin); +} + +void MainWindow::clear() +{ +	mainwindow_playerview->clear(); +} + +void MainWindow::event_text(const std::string & text) +{ +	mainwindow_playerview->event_text(text); +} + +void MainWindow::draw() +{ +	// the mianwindow is only drawn when the application is connected +	// and the loader screen is not shown +	// FIXME the mainwindow should alway be visible, except in the loader screen +	 +	mainwindow_devinfo->set_visible(draw_devinfo->value() ? true : false); +	mainwindow_statsinfo->set_visible(draw_stats->value() ? true : false); +	mainwindow_keyinfo->set_visible(draw_keypress->value() ? true : false); +	if (draw_clock->value() <= 0) { +		mainwindow_clock->set_mode(ClockInfoWidget::ClockOff); +	} else if (draw_clock->value() >= 2) { +		mainwindow_clock->set_mode(ClockInfoWidget::Clock12Hours); +	} else { +		mainwindow_clock->set_mode(ClockInfoWidget::Clock24Hours); +	} + + +	// FIXME - either draw one of the menus or draw the playerview +	if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size())) { +		mainwindow_playerview->hide(); +	} else { +		mainwindow_playerview->show(); +		mainwindow_playerview->set_focus(); + +	} +} + +} | 
