CLASS::CLASS()
{
	MyGUI::WindowPtr win = dynamic_cast<MyGUI::WindowPtr>(mMainWidget);

	m_single_player->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickSelectTerrainButton);
	m_rig_editor->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickRigEditorButton);
	m_settings->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickSettingButton);
	m_about->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickAboutButton);
	m_exit->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickExitButton);
	m_multi_player->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickMultiPlayerButton);

	m_single_player->setCaption(_L("Singleplayer"));
	m_rig_editor->setCaption(_L("Rig-Editor"));
	m_settings->setCaption(_L("Settings"));
	m_about->setCaption(_L("About"));
	m_exit->setCaption(_L("Quit"));
	m_multi_player->setCaption(_L("Multiplayer"));

	win->setCaption(_L("Main Menu"));
	win->setMovable(false);

	if (!BSETTING("DevMode", false))
	{
		m_multi_player->setEnabled(false);
		m_rig_editor->setEnabled(false);
	}

	Hide();
}
CLASS::CLASS()
{
	MyGUI::WindowPtr win = dynamic_cast<MyGUI::WindowPtr>(mMainWidget);
	win->setMovable(false);

	m_resume_game->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickResumeButton);
	m_change_map->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickChangeMapButton);
	m_back_to_menu->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickBackToMenuButton);
	m_rig_editor->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickRigEditorButton);
	m_quit_game->eventMouseButtonClick += MyGUI::newDelegate(this, &CLASS::eventMouseButtonClickQuitButton);
}
PropertiesPanelView::PropertiesPanelView() : BaseLayout("PropertiesPanelView.layout")
{
	DEFAULT_VALUE = localise("ColourDefault") + DEFAULT_STRING;
	ERROR_VALUE = localise("ColourError");

	assignBase(mPanelView, "scroll_View");

	MyGUI::WindowPtr window = mMainWidget->castType<MyGUI::Window>(false);
	if (window != nullptr) {
		window->eventWindowChangeCoord = MyGUI::newDelegate(this, &PropertiesPanelView::notifyWindowChangeCoord);
		mOldSize = window->getSize();
	}

	mPanelMainProperties = new PanelMainProperties();
	mPanelView->addItem(mPanelMainProperties);
	mPanelMainProperties->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);
	mPanelMainProperties->eventSetPositionText = MyGUI::newDelegate(this, &PropertiesPanelView::setPositionText);

	mPanelTypeProperties = new PanelProperties();
	mPanelView->addItem(mPanelTypeProperties);
	mPanelTypeProperties->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);

	mPanelGeneralProperties = new PanelProperties();
	mPanelView->addItem(mPanelGeneralProperties);
	mPanelGeneralProperties->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);

	mPanelEvents = new PanelProperties();
	mPanelView->addItem(mPanelEvents);
	mPanelEvents->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);

	mPanelItems = new PanelItems();
	mPanelView->addItem(mPanelItems);

	mPanelUserData = new PanelUserData();
	mPanelView->addItem(mPanelUserData);

	mPanels.push_back(mPanelMainProperties);
	mPanels.push_back(mPanelTypeProperties);
	mPanels.push_back(mPanelGeneralProperties);
	mPanels.push_back(mPanelEvents);
	mPanels.push_back(mPanelItems);
	mPanels.push_back(mPanelUserData);

	current_widget = nullptr;

	// create widget rectangle
	current_widget_rectangle = MyGUI::Gui::getInstance().createWidget<MyGUI::Window>("StretchRectangle", MyGUI::IntCoord(), MyGUI::Align::Default, "LayoutEditor_Rectangle");
	current_widget_rectangle->eventWindowChangeCoord = newDelegate(this, &PropertiesPanelView::notifyRectangleResize);
	current_widget_rectangle->eventMouseButtonDoubleClick = newDelegate(mPanelItems, &PanelItems::notifyRectangleDoubleClick);
	current_widget_rectangle->eventKeyButtonPressed = newDelegate(this, &PropertiesPanelView::notifyRectangleKeyPressed);

	arrow_move = false;
}
void PropertiesPanelView::notifyWindowChangeCoord(MyGUI::WindowPtr _sender)
{
	const MyGUI::IntSize & size = _sender->getSize();
	if (size != mOldSize) {
		mOldSize = size;
		mPanelView->setNeedUpdate();
	}
}
void PropertiesPanelView::notifyRectangleResize(MyGUI::WindowPtr _sender)
{
	if (!_sender->isVisible()) return;
	// найдем соответствующий контейнер виджета и переместим/раст¤нем
	WidgetContainer * widgetContainer = EditorWidgets::getInstance().find(current_widget);
	if (WidgetTypes::getInstance().find(current_widget->getTypeName())->resizeable)
	{
		MyGUI::IntCoord coord = convertCoordToParentCoord(_sender->getCoord(), current_widget);
		MyGUI::IntCoord old_coord = current_widget->getCoord();
		// align to grid
		if (!MyGUI::InputManager::getInstance().isShiftPressed() && !arrow_move){
			if ((old_coord.width == coord.width) && (old_coord.height == coord.height)) // если только перемещаем
			{
				coord.left = toGrid(coord.left + grid_step-1 - old_coord.left) + old_coord.left;
				coord.top = toGrid(coord.top + grid_step-1 - old_coord.top) + old_coord.top;
			}
			else // если раст¤гиваем
			{
				if (old_coord.left != coord.left){
					coord.left = toGrid(coord.left + grid_step-1);
					coord.width = old_coord.right() - coord.left;
				}else if (old_coord.width != coord.width){
					coord.width = toGrid(coord.width + old_coord.left) - old_coord.left;
				}

				if (old_coord.top != coord.top){
					coord.top = toGrid(coord.top + grid_step-1);
					coord.height = old_coord.bottom() - coord.top;
				}else if (old_coord.height != coord.height){
					coord.height = toGrid(coord.height + old_coord.top) - old_coord.top;
				}
			}
		}
		arrow_move = false;

		current_widget->setCoord(coord);
		// update coord because of current_widget can have MinMax size
		coord = current_widget->getCoord();
		setPositionText(widgetContainer->position());

		UndoManager::getInstance().addValue(PR_POSITION);
	}
	current_widget_rectangle->setCoord(current_widget->getAbsoluteCoord());
}
Beispiel #6
0
void DemoKeeper::createScene()
{
    mGraphView = 0;
    // потемнее скин
    //mGUI->load("core_theme_black_orange.xml");
    //mGUI->load("core_skin.xml");
    //mNodeWindow1 = mNodeWindow2 = mNodeWindow3 = nullptr;
    //mIsDrug = false;

    mCanvas1Size = 350;
    mCanvas2Size = 300;
    mCanvas3Size = 300;

    //mCanvasFactory = new MyGUI::factory::CanvasFactory();
    //mTestRenderBoxFactory = new MyGUI::factory::TestRenderBoxFactory();
    MyGUI::EditPtr edit = mGUI->createWidget<MyGUI::Edit>("EditStretch", MyGUI::IntCoord(40, 600, 200, 50), MyGUI::Align::Default, "Overlapped");
    edit->setEditMultiLine(true);
    edit->setOverflowToTheLeft(true);
    edit->setMaxTextLength(60);
    edit->addText("1234jkdfhgkjahgsdkjfagsdkjfgakjdhgkfajhgsdkjsdhgkajgksdjjsdghf");
    edit->setTextIntervalColour(2, 10, MyGUI::Colour::Red);

    MyGUI::WindowPtr wnd = mGUI->createWidget<MyGUI::Window>("WindowCS", MyGUI::IntCoord(400, 400, 400, 400), MyGUI::Align::Default, "Overlapped");
    mTestRenderBox1 = wnd->createWidget<MyGUI::RenderBox>( "TestRenderBox", MyGUI::IntCoord( MyGUI::IntPoint(), wnd->getClientCoord().size() ), MyGUI::Align::Stretch );
    //mTestRenderBox1->setCamera( mCamera );
    //mTestRenderBox1->setBackgroungColour(Ogre::ColourValue::ZERO);

    mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject( mSceneMgr->createEntity( "axes", "axes.mesh" ) );

    mSceneMgr->getRootSceneNode()->getChildIterator().peekNextValue()->scale( Ogre::Vector3( 4 ) );

    wraps::RenderBoxWrap * box = new wraps::RenderBoxWrap(mTestRenderBox1);
    box->injectObject("axes.mesh");
    box->setAutoRotation(true);
    box->setMouseRotation(true);
    box->setViewScale(true);

    // первая мета текстура
    // мы по евенту лочим и добавляем в текстуру данные и все
    // Re: без кеша
    mPanel1 = mGUI->createWidget<MyGUI::Window>("WindowCS", MyGUI::IntCoord(10, 10, mCanvas1Size, mCanvas1Size), MyGUI::Align::Default, "Overlapped");
    mPanel1->setCaption( Ogre::UTFString( "Const size - stretches" ) );
    mCanvas1 = mPanel1->createWidget< MyGUI::Canvas >( "Canvas", MyGUI::IntCoord(0, 0, 256, 256), MyGUI::Align::Stretch);
    mCanvas1->createTexture( 256, 256, MyGUI::Canvas::TRM_PT_CONST_SIZE ); // создаём ровно то, что сказали
    mCanvas1->requestUpdateCanvas = MyGUI::newDelegate( this, &DemoKeeper::requestUpdateCanvas1 );

    mPanel1->setAutoAlpha(true);
    //MyGUI::StaticImagePtr image1 = mPanel1->createWidget<MyGUI::StaticImage>("StaticImage", MyGUI::IntCoord(0, 0, mCanvas1Size, mCanvas1Size), MyGUI::Align::Stretch);
    //image1->setImageTexture( mCanvas1->getName() );

    //mPanel1 = mGUI->createWidget<MyGUI::Window>("WindowCS", MyGUI::IntCoord(10, 10, mCanvas1Size, mCanvas1Size), MyGUI::Align::Default, "Overlapped");
    //mPanel1->setCaption( Ogre::UTFString( "Const size - stretches" ) );
    //mCanvas1 = mPanel1->createWidget< MyGUI::Canvas >( "Canvas", MyGUI::IntCoord(MyGUI::IntPoint(), mPanel1->getClientCoord().size()), MyGUI::Align::Stretch);
    //mCanvas1->createTexture( mCanvas1Size, mCanvas1Size, MyGUI::Canvas::TRM_PT_CONST_SIZE ); // создаём ровно то, что сказали
    //mCanvas1->requestUpdateCanvas = MyGUI::newDelegate( this, &DemoKeeper::requestUpdateCanvas1 );
    ////MyGUI::StaticImagePtr image1 = mPanel1->createWidget<MyGUI::StaticImage>("StaticImage", MyGUI::IntCoord(0, 0, mCanvas1Size, mCanvas1Size), MyGUI::Align::Stretch);
    ////image1->setImageTexture( mCanvas1->getName() );

    //mPanel2 = mGUI->createWidget<MyGUI::Window>("WindowCS", MyGUI::IntCoord(310, 10, mCanvas2Size, mCanvas2Size), MyGUI::Align::Default, "Overlapped");
    //mPanel2->setCaption( Ogre::UTFString( "Pixel in pixel - recreates" ) );
    //mCanvas2 = mPanel2->createWidget< MyGUI::Canvas >( "Canvas", MyGUI::IntCoord(MyGUI::IntPoint(), mPanel2->getClientCoord().size()), MyGUI::Align::Stretch);
    //mCanvas2->createTexture( MyGUI::Canvas::TRM_PT_VIEW_REQUESTED ); // текстура с размерами степень двойки - потому что не задали размеры
    ////mCanvas2->loadTexture( "wallpaper0.jpg" );
    //mCanvas2->requestUpdateCanvas = MyGUI::newDelegate( this, &DemoKeeper::requestUpdateCanvas2 );


    // третья мета текстура
    // мы запоминаем примитив(ы) для рендера и говорим текстуре что данные обновились
    // а данные обновляем в методу апдейт
    // Re: кеша нет - примитивы
    mPanel3 = mGUI->createWidget<MyGUI::Window>("WindowCS", MyGUI::IntCoord(410, 10, 600, mCanvas3Size), MyGUI::Align::Default, "Overlapped");
    mPanel3->setCaption( Ogre::UTFString( "Pixel in pixel(primitives) - recreates" ) );
    mCanvas3 = mPanel3->createWidget< MyGUI::Canvas >("Canvas", MyGUI::IntCoord(MyGUI::IntPoint(), mPanel3->getClientCoord().size()), MyGUI::Align::Stretch);
    mCanvas3->createTexture( MyGUI::Canvas::TRM_PT_VIEW_REQUESTED);
    mCanvas3->requestUpdateCanvas = MyGUI::newDelegate( this, &DemoKeeper::requestUpdateCanvas3 );
    mCanvas3->updateTexture();

    /*mNodeWindow1 = mPanel3->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowSmallC", MyGUI::IntCoord(20, 50, 100, 80), MyGUI::Align::Default);
    mNodeWindow1->setCaption( "Node1" );
    mNodeWindow1->eventWindowChangeCoord = MyGUI::newDelegate(this, &DemoKeeper::notifyWindowChangeCoord);

    MyGUI::ButtonPtr button = mNodeWindow1->createWidget<MyGUI::Button>("ButtonRound", MyGUI::IntCoord(1, 40, 9, 9), MyGUI::Align::Default);
    button->eventMouseButtonPressed = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonPressed);
    button->eventMouseButtonReleased = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonReleased);
    button->eventMouseDrag = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseDrag);
    button->setUserString("NodeLink", "true");

    button = mNodeWindow1->createWidget<MyGUI::Button>("ButtonRound", MyGUI::IntCoord(mNodeWindow1->getWidth() - 12, 40, 9, 9), MyGUI::Align::Right | MyGUI::Align::Top);
    button->eventMouseButtonPressed = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonPressed);
    button->eventMouseButtonReleased = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonReleased);
    button->eventMouseDrag = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseDrag);
    button->setUserString("NodeLink", "false");

    mNodeWindow2 = mPanel3->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowSmallC", MyGUI::IntCoord(220, 150, 100, 80), MyGUI::Align::Default);
    mNodeWindow2->setCaption( "Node2" );
    mNodeWindow2->eventWindowChangeCoord = MyGUI::newDelegate(this, &DemoKeeper::notifyWindowChangeCoord);

    button = mNodeWindow2->createWidget<MyGUI::Button>("ButtonRound", MyGUI::IntCoord(1, 40, 9, 9), MyGUI::Align::Default);
    button->eventMouseButtonPressed = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonPressed);
    button->eventMouseButtonReleased = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonReleased);
    button->eventMouseDrag = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseDrag);
    button->setUserString("NodeLink", "true");

    button = mNodeWindow2->createWidget<MyGUI::Button>("ButtonRound", MyGUI::IntCoord(mNodeWindow2->getWidth() - 12, 40, 9, 9), MyGUI::Align::Right | MyGUI::Align::Top);
    button->eventMouseButtonPressed = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonPressed);
    button->eventMouseButtonReleased = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonReleased);
    button->eventMouseDrag = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseDrag);
    button->setUserString("NodeLink", "false");

    mNodeWindow3 = mPanel3->createWidget<MyGUI::Window>(MyGUI::WidgetStyle::Overlapped, "WindowSmallC", MyGUI::IntCoord(420, 50, 100, 80), MyGUI::Align::Default);
    mNodeWindow3->setCaption( "Node3" );
    mNodeWindow3->eventWindowChangeCoord = MyGUI::newDelegate(this, &DemoKeeper::notifyWindowChangeCoord);

    button = mNodeWindow3->createWidget<MyGUI::Button>("ButtonRound", MyGUI::IntCoord(1, 40, 9, 9), MyGUI::Align::Default);
    button->eventMouseButtonPressed = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonPressed);
    button->eventMouseButtonReleased = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonReleased);
    button->eventMouseDrag = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseDrag);
    button->setUserString("NodeLink", "true");

    button = mNodeWindow3->createWidget<MyGUI::Button>("ButtonRound", MyGUI::IntCoord(mNodeWindow3->getWidth() - 12, 40, 9, 9), MyGUI::Align::Right | MyGUI::Align::Top);
    button->eventMouseButtonPressed = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonPressed);
    button->eventMouseButtonReleased = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseButtonReleased);
    button->eventMouseDrag = MyGUI::newDelegate(this, &DemoKeeper::notifyMouseDrag);
    button->setUserString("NodeLink", "false");

    mCanvas3->updateTexture();*/

    /*mGraphView = new wraps::BaseGraphView("", mCanvas3);

    GraphNodeSimple * node1 = new GraphNodeSimple("Node1");
    mGraphView->addItem(node1);
    //mGraphView->removeItem(node1);

    GraphNodeSimple * node2 = new GraphNodeSimple("Node2");
    mGraphView->addItem(node2);

    GraphNodeSimple * node3 = new GraphNodeSimple("Node3");
    mGraphView->addItem(node3);*/
}