Esempio n. 1
0
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CTileGenDialog::CTileGenDialog( Panel *parent, const char *name ) : BaseClass( parent, name )
{
	Assert( !g_pTileGenDialog );
	g_pTileGenDialog = this;

	m_pMapLayout = new CMapLayout();
	m_pLayoutSystem = NULL;
	m_VMFExporter = new VMFExporter();
	m_pGenerationOptions = new KeyValues( "EmptyOptions" );

	vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile( "tilegen/tilegen_scheme.res", "GAME" );
	SetScheme( scheme );

	if ( !g_bAddedTileGenLocalization )
	{
		g_pVGuiLocalize->AddFile( "tilegen/tilegen_english.txt" );
		g_bAddedTileGenLocalization = true;
	}

	m_fTileSize = 30.0f;

	m_bShowExits = true;
	m_bShowTileSquares = true;
	m_iStartDragX = -1;
	m_iStartDragY = -1;
	m_iStartRubberBandX = -1;
	
	SetSize(384, 420);
	SetMinimumSize(384, 420);
	
	m_pCurrentThemeDetails = new CThemeDetails(this, "CurrentThemeDetails", NULL);
	m_pCurrentThemeDetails->m_iDesiredWidth = 356;
	m_pTemplateListContainer = new CScrollingWindow(this, "TemplateListWindow");
	m_pTemplateListPanel = new CRoomTemplateListPanel(m_pTemplateListContainer, "TemplateListPanel");
	m_pTemplateFilter = new TextEntry( this, "TemplateFilter" );
	m_pShowExitsCheck = new vgui::CheckButton(this, "ShowExitsCheck", "");
	m_pShowExitsCheck->SetSelected(m_bShowExits);
	m_pShowTileSquaresCheck = new vgui::CheckButton(this, "ShowTileSquaresCheck", "");
	m_pShowTileSquaresCheck->SetSelected(m_bShowTileSquares);

	m_pPropertySheet = new vgui::PropertySheet( this, "PropertySheet" );
	m_pLayoutPage = new CTileGenLayoutPage( m_pPropertySheet, "TileGenLayoutPage" );
	m_pLayoutSystemPage = new CTilegenLayoutSystemPage( m_pPropertySheet, "TilegenLayoutSystemPage" );
	m_pLayoutSystemPage->UpdateList();
	m_pPropertySheet->AddPage( m_pLayoutPage, "Layout" );
	m_pPropertySheet->AddPage( m_pLayoutSystemPage, "Missions" );

	m_pCursorPanel = new CRoomTemplatePanel(this, "CursorRoomTemplatePanel");
	m_pCursorPanel->SetMouseInputEnabled(false);
	m_pCursorPanel->SetVisible(false);
	m_pCursorTemplate = NULL;

	m_pTemplateListContainer->SetChildPanel( m_pTemplateListPanel );

	CLevelTheme::LoadLevelThemes();
	OnUpdateCurrentTheme(NULL);

	// setup the menu
	m_pMenuBar = new MenuBar(this, "TileGenMenuBar");
	MenuButton *pFileMenuButton = new MenuButton(this, "FileMenuButton", "&File");
	Menu *pFileMenu = new Menu(pFileMenuButton, "TileGenFileMenu");	
	pFileMenu->AddMenuItem("&New Map Layout",  "NewMapLayout", this);
	pFileMenu->AddMenuItem("&Open Map Layout...",  "OpenMapLayout", this);
	pFileMenu->AddMenuItem("&Open Current Map Layout...",  "OpenCurrentMapLayout", this);
	pFileMenu->AddMenuItem("&Save Map Layout",  "SaveMapLayout", this);
	pFileMenu->AddMenuItem("&Save Map Layout As...",  "SaveMapLayoutAs", this);
	pFileMenu->AddSeparator();
	pFileMenu->AddMenuItem("&Export VMF", "ExportVMF", this);
	pFileMenu->AddMenuItem("&Export VMF and Play Map", "ExportAndPlay", this);
	pFileMenu->AddMenuItem("&Export VMF and Play Without Aliens", "ExportAndPlayClean", this);	
	pFileMenuButton->SetMenu(pFileMenu);
	m_pMenuBar->AddButton(pFileMenuButton);

	MenuButton *pToolsMenuButton = new MenuButton(this, "ToolsMenuButton", "&Tools");
	m_pToolsMenu = new Menu(pToolsMenuButton, "TileGenToolsMenu");	
	pToolsMenuButton->SetMenu(m_pToolsMenu);
	m_pMenuBar->AddButton(pToolsMenuButton);
	//m_pToolsMenu->AddMenuItem("Push Encounters Apart", "PushEncountersApart", this);		// used to debug encounter push apart
	m_pToolsMenu->AddMenuItem("Generate &Thumbnails", "GenerateThumbnails", this);
	//m_pToolsMenu->AddMenuItem("&Location Layout Editor", "LocationLayoutEditor", this);
	m_pToolsMenu->AddMenuItem("&Check Room Templates for Errors", "TileCheck", this);
	m_pToolsMenu->AddSeparator();
	m_nShowDefaultParametersMenuItemID = m_pToolsMenu->AddCheckableMenuItem( "&Show Optional Parameters", "ShowOptionalParameters", this );
	m_nShowAddButtonsMenuItemID = m_pToolsMenu->AddCheckableMenuItem( "&Show 'Add' Buttons", "ShowAddButtons", this );
	// Get the checked menu items in-sync with editor settings.
	m_pToolsMenu->SetMenuItemChecked( m_nShowDefaultParametersMenuItemID, true );
	m_pToolsMenu->SetMenuItemChecked( m_nShowAddButtonsMenuItemID, true );
	m_pLayoutSystemPage->GetEditor()->ShowOptionalValues( true );
	m_pLayoutSystemPage->GetEditor()->ShowAddButtons( true );

	// disable keyboard input on the menu, otherwise once you click there, this dialog never gets key input again (is there a better way to do this and maintain keyboard shortcuts for the menu?)
	pFileMenuButton->SetKeyBoardInputEnabled(false);
	pFileMenu->SetKeyBoardInputEnabled(false);
	m_pMenuBar->SetKeyBoardInputEnabled(false);

	m_pZoomInButton = new vgui::Button( this, "ZoomInButton", "+", this, "ZoomIn" );
	m_pZoomOutButton = new vgui::Button( this, "ZoomOutButton", "-", this, "ZoomOut" );
	m_pCoordinateLabel = new vgui::Label( this, "CoordinateLabel", "" );
	
	// make sure the window get a tick all the time (could change this to only tick on necessary states?)
	vgui::ivgui()->AddTickSignal( GetVPanel(), 0 );
}
Esempio n. 2
0
/**
*  @brief
*    Constructor
*/
TestWindow::TestWindow(Widget *pParent) : Window(pParent),
	EventHandlerTrayClicked(&TestWindow::TrayClicked, this),
	EventHandlerClicked(&TestWindow::ButtonClicked, this),
	EventHandlerPressed(&TestWindow::ButtonPressed, this),
	EventHandlerReleased(&TestWindow::ButtonReleased, this),
	EventHandlerMenu(&TestWindow::MenuClicked, this),
	m_pLabel(nullptr),
	m_pButton(nullptr),
	m_pToggleButton(nullptr),
	m_pClickTest(nullptr),
	m_pPressedTest(nullptr),
	m_pBitmapButton(nullptr),
	m_pBitmapToggleButton(nullptr),
	m_cMenu(*GetGui()),
	m_pMenuBar(nullptr),
//	m_pTabBar(nullptr),
	m_pPopupMenu(nullptr),
	m_cTrayIcon(*GetGui()),
	m_bClicked(false)
{
	// Create a tray icon
	m_cTrayIcon.SetTooltip(L"Hallo!!");
	m_cTrayIcon.SetIcon(Image(*Gui::GetSystemGui()));
	m_cTrayIcon.EventMouseButtonDown.Connect(EventHandlerTrayClicked);

	// Create some widgets
	m_pLabel = new Label(GetContentWidget());
		m_pLabel->SetText("Hallo!");
		m_pLabel->SetPos(Vector2i(10, 30));
		m_pLabel->SetSize(Vector2i(200, 32));
		m_pLabel->SetVisible(true);
	m_pButton = new Button(GetContentWidget());
		m_pButton->SetImage(Image(*Gui::GetSystemGui(), "PLGui/copy.png"));
		m_pButton->SetText("Button");
		m_pButton->SetPos(Vector2i(10, 70));
		m_pButton->SetSize(Vector2i(120, 32));
		m_pButton->SetVisible(true);
		m_pButton->SetRepeat(true);
		m_pButton->SetRepeatDelay(1000);
		m_pButton->SetRepeatInterval(250);
	m_pToggleButton = new ToggleButton(GetContentWidget());
		m_pToggleButton->SetText("Toggle");
		m_pToggleButton->SetPos(Vector2i(10, 110));
		m_pToggleButton->SetSize(Vector2i(120, 32));
		m_pToggleButton->SetVisible(true);
	m_cCheckGroup.SetExclusive(false);
	for (int i=0; i<4; i++) {
		m_pCheckBoxes[i] = new CheckBox(GetContentWidget());
			m_pCheckBoxes[i]->SetGroup(&m_cCheckGroup);
			m_pCheckBoxes[i]->SetPartiallyAllowed(true);
			m_pCheckBoxes[i]->SetState(PartiallyChecked);
			m_pCheckBoxes[i]->SetText(String("Check Box ") + i);
			m_pCheckBoxes[i]->SetPos(Vector2i(10, 150 + i*20));
			m_pCheckBoxes[i]->SetSize(Vector2i(100, 20));
			m_pCheckBoxes[i]->SetVisible(true);
		m_pRadioButtons[i] = new RadioButton(GetContentWidget());
			m_pRadioButtons[i]->SetGroup(&m_cRadioGroup);
			m_pRadioButtons[i]->SetState(Checked);
			m_pRadioButtons[i]->SetText(String("Radio Button ") + i);
			m_pRadioButtons[i]->SetPos(Vector2i(150, 150 + i*20));
			m_pRadioButtons[i]->SetSize(Vector2i(100, 20));
			m_pRadioButtons[i]->SetVisible(true);
	}

	m_pClickTest = new Widget(GetContentWidget());
		m_pClickTest->SetBackgroundColor(Color4::Red);
		m_pClickTest->SetPos(Vector2i(150, 70));
		m_pClickTest->SetSize(Vector2i(32, 32));
		m_pClickTest->SetVisible(true);
	m_pPressedTest = new Widget(GetContentWidget());
		m_pPressedTest->SetBackgroundColor(Color4::Blue);
		m_pPressedTest->SetPos(Vector2i(200, 70));
		m_pPressedTest->SetSize(Vector2i(32, 32));
		m_pPressedTest->SetVisible(true);
	m_pBitmapButton = new BitmapButton(GetContentWidget());
		m_pBitmapButton->SetImageEnabled (Image(*Gui::GetSystemGui(), "PLGui/button.png"));
		m_pBitmapButton->SetImageDisabled(Image(*Gui::GetSystemGui(), "PLGui/button-inactive.png"));
		m_pBitmapButton->SetImageSelected(Image(*Gui::GetSystemGui(), "PLGui/button-over.png"));
		m_pBitmapButton->SetImagePressed (Image(*Gui::GetSystemGui(), "PLGui/button-pressed.png"));
		m_pBitmapButton->SetPos(Vector2i(10, 230));
		m_pBitmapButton->SetSize(Vector2i(64, 64));
		m_pBitmapButton->SetVisible(true);
	m_pBitmapToggleButton = new BitmapToggleButton(GetContentWidget());
		m_pBitmapToggleButton->SetImageDisabled  (Image(*Gui::GetSystemGui(), "PLGui/button-inactive.png"));
		m_pBitmapToggleButton->SetImageUnselected(NotChecked,		Image(*Gui::GetSystemGui(), "PLGui/button-off.png"));
		m_pBitmapToggleButton->SetImageUnselected(PartiallyChecked,	Image(*Gui::GetSystemGui(), "PLGui/button-on.png"));
		m_pBitmapToggleButton->SetImageUnselected(Checked,			Image(*Gui::GetSystemGui(), "PLGui/button-on.png"));
		m_pBitmapToggleButton->SetImageSelected  (NotChecked,		Image(*Gui::GetSystemGui(), "PLGui/button-over-off.png"));
		m_pBitmapToggleButton->SetImageSelected  (PartiallyChecked,	Image(*Gui::GetSystemGui(), "PLGui/button-over-on.png"));
		m_pBitmapToggleButton->SetImageSelected  (Checked,			Image(*Gui::GetSystemGui(), "PLGui/button-over-on.png"));
		m_pBitmapToggleButton->SetPos(Vector2i(10, 300));
		m_pBitmapToggleButton->SetSize(Vector2i(64, 64));
		m_pBitmapToggleButton->SetVisible(true);

	// Connect event handlers to button
	m_pButton->SignalClicked .Connect(EventHandlerClicked);
	m_pButton->SignalPressed .Connect(EventHandlerPressed);
	m_pButton->SignalReleased.Connect(EventHandlerReleased);

	// Create menu
	Menu *pMenuFile = new Menu(*GetGui());
		pMenuFile->SetText("&File");
		pMenuFile->AddItem("&Open");
		pMenuFile->AddItem("&Close");
		pMenuFile->AddSeparator();
		pMenuFile->AddItem("&Quit");
	Menu *pMenuEdit = new Menu(*GetGui());
		pMenuEdit->SetText("&Edit");
		pMenuEdit->AddItem("&Copy");
		pMenuEdit->AddItem("Cu&t");
		pMenuEdit->AddItem("&Paste");
	Menu *pMenuView = new Menu(*GetGui());
		pMenuView->SetText("&View");
		pMenuView->AddItem("View &All");
		pMenuView->AddItem("View &None");
	Menu *pMenuWindow = new Menu(*GetGui());
		pMenuWindow->SetText("&Window");
		pMenuWindow->AddItem("&Next");
		pMenuWindow->AddItem("&Previous");
		pMenuWindow->AddItem("&Close");
		pMenuWindow->AddItem( "Close &All");
	Menu *pMenuHelp = new Menu(*GetGui());
		pMenuHelp->SetText("&Help");
		pMenuHelp->AddItem("&Help");
		pMenuHelp->AddItem("&About");
	m_cMenu.SetText("&Menu");
	m_cMenu.AddSubMenu(pMenuFile);
	m_cMenu.AddSubMenu(pMenuEdit);
	m_cMenu.AddSubMenu(pMenuView);
	m_cMenu.AddSubMenu(pMenuWindow);
	m_cMenu.AddSubMenu(pMenuHelp);
	m_cMenu.AddSeparator();
	m_cMenu.AddItem("&Restore");
	m_cMenu.AddSeparator();

	// Add a menu bar
	m_pMenuBar = new MenuBar(GetContentWidget());
//		m_pMenuBar->SetSubmenuOrientationVert(Up);
		m_pMenuBar->SetMenu(&m_cMenu);
		m_pMenuBar->SetPos(Vector2i::Zero);
//		m_pMenuBar->SetSize(Vector2i(GetContentWidget()->GetSize().x, 26));
		m_pMenuBar->SetSize(Vector2i(640, 26));
		m_pMenuBar->SetVisible(true);

	// Add a tab bar
	/*
	m_pTabBar = new TabBar(GetContentWidget());
		m_pTabBar->AddTab("Test1");
		m_pTabBar->AddTab("Test2");
		m_pTabBar->AddTab("Test3");
		m_pTabBar->AddTab("Test4");
		m_pTabBar->AddTab("Test5");
		m_pTabBar->AddTab("Test6");
		m_pTabBar->SetPos(Vector2i(0, 370));
//		m_pTabBar->SetSize(Vector2i(GetContentWidget()->GetSize().x, 20));
		m_pTabBar->SetSize(Vector2i(640, 20));
		m_pTabBar->SetVisible(true);
	*/

	// Add a popup menu
	m_pPopupMenu = new PopupMenu(GetContentWidget());
		m_pPopupMenu->SetMenu(&m_cMenu);
		m_pPopupMenu->SetPos(Vector2i(300, 70));
		m_pPopupMenu->SetSize(Vector2i(100, 200));
		m_pPopupMenu->SetVisible(true);

	// Connect event handlers to menus
	m_pMenuBar->SignalItemClicked.Connect(EventHandlerMenu);
	m_pPopupMenu->SignalItemClicked.Connect(EventHandlerMenu);
}