File: SelectionWidget.h

package info (click to toggle)
spring 98.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 41,928 kB
  • ctags: 60,665
  • sloc: cpp: 356,167; ansic: 39,434; python: 12,228; java: 12,203; awk: 5,856; sh: 1,719; xml: 997; perl: 405; php: 253; objc: 194; makefile: 72; sed: 2
file content (96 lines) | stat: -rw-r--r-- 2,235 bytes parent folder | download
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
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef SELECTIONWIDGET_H
#define SELECTIONWIDGET_H

#include <string>
#include <boost/bind.hpp>

#include "aGui/GuiElement.h"
#include "aGui/Window.h"
#include "aGui/List.h"
#include "aGui/Gui.h"
#include "aGui/VerticalLayout.h"
#include "aGui/HorizontalLayout.h"
#include "aGui/Button.h"
#include "aGui/LineEdit.h"
#include "aGui/TextElement.h"

namespace agui
{
class Button;
class TextElement;
}

class ListSelectWnd : public agui::Window
{
public:
	ListSelectWnd(const std::string& title) : agui::Window(title)
	{
		agui::gui->AddElement(this);
		SetPos(0.5, 0.2);
		SetSize(0.4, 0.7);

		agui::VerticalLayout* modWindowLayout = new agui::VerticalLayout(this);
		list = new agui::List(modWindowLayout);
		list->FinishSelection.connect(boost::bind(&ListSelectWnd::SelectButton, this));
		agui::HorizontalLayout* buttons = new agui::HorizontalLayout(modWindowLayout);
		buttons->SetSize(0.0f, 0.04f, true);
		agui::Button* select = new agui::Button("Select", buttons);
		select->Clicked.connect(boost::bind(&ListSelectWnd::SelectButton, this));
		agui::Button* cancel = new agui::Button("Close", buttons);
		cancel->Clicked.connect(boost::bind(&ListSelectWnd::CancelButton, this));
		GeometryChange();
	}

	boost::signals2::signal<void (std::string)> Selected;
	agui::List* list;

private:
	void SelectButton()
	{
		list->SetFocus(false);
		Selected(list->GetCurrentItem());
	}
	void CancelButton()
	{
		WantClose();
	}
};

class SelectionWidget : public agui::GuiElement
{
public:
	static const std::string NoModSelect;
	static const std::string NoMapSelect;
	static const std::string NoScriptSelect;
	static const std::string SandboxAI;

	SelectionWidget(agui::GuiElement* parent);
	~SelectionWidget();

	void ShowModList();
	void ShowMapList();
	void ShowScriptList();

	void SelectMod(std::string);
	void SelectScript(std::string);
	void SelectMap(std::string);

	std::string userScript;
	std::string userMap;
	std::string userMod;

private:
	void CleanWindow();

	agui::Button* mod;
	agui::TextElement* modT;
	agui::Button* map;
	agui::TextElement* mapT;
	agui::Button* script;
	agui::TextElement* scriptT;
	ListSelectWnd* curSelect;
};

#endif