Пример #1
0
Editor::Editor(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);
	UIInitHelper();

	mEngine = AGE::Engine::GetInstance();
	mEngine->StartUp((HWND)ui.widget->winId());
	AGE::GetLevelManager()->LoadLevel<EditorLevel>(ui.widget);

	connect(ui.widget, &RenderWidget::onRefresh, this, &Editor::RenderWidgetUpdate);

	connect(ui.widget, &RenderWidget::onMousePress, [this](QPoint point){
		if (AGE::GetScene()) {
			AGE::SceneNode* node = AGE::GetScene()->GetCurrentCamera()->PickAt(point.x(), point.y());
			printf("pick %p\n", node);
			ui.propertyWidget->clear();
			if (!node)
				return;

			if (auto p = node->GetUserData<PropertySceneNode>(0)) {
				QtVariantPropertyManager *variantManager = new QtVariantPropertyManager();
				QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory();
				ui.propertyWidget->setFactoryForManager(variantManager, variantFactory);
				p->AddProperties(ui.propertyWidget, variantManager);
			}
		}
	});

	connect(ui.widget, &RenderWidget::onResize, [this](QSize newSize, QSize oldSize){
		AGE::RenderEngine::GetInstance()->ResizeToFit();
		ui.widget->update();
	});

	connect(ui.widget, &RenderWidget::onDrag, [this](QPoint delta){
		if (GetEditorLevel()) {
			GetEditorLevel()->RotateCamera(delta.x(), delta.y());
		}
	});

	connect(ui.widget, &RenderWidget::onWheel, [this](int delta){
		if (GetEditorLevel()) {
			GetEditorLevel()->AdjustDistance(delta);
		}
	});

	connect(ui.actionSave, &QAction::triggered, [this](){
		if (mProject) {
			mProject->Save();
			if (mProject->GetCurrentScene())
				mProject->GetCurrentScene()->Save();
		}
	});

	connect(ui.actionCS, &QAction::triggered, [](){
		MDLImporterDlg w;
		w.exec();
	});
	connect(ui.action_N, &QAction::triggered, this, &Editor::OnActionNewProject);
	connect(ui.action_O, &QAction::triggered, [this](){
		QString path = QFileDialog::getOpenFileName(this, tr("打开工程文件"), "", tr("AGE Project (*.aproj)"));
		if (path.isEmpty())
			return;

		mProject = Project::Load(path);
		if (!mProject) {
			QMessageBox::information(this, tr("提示"), tr("读取项目文件失败"));
			return;
		}
		ProjectContentChanged();
	});

	connect(ui.actionTest, &QAction::triggered, [this](){
		mProject = Project::Load("D:\\Projects\\AGEProjects\\test\\123.aproj");
		mProject->OpenScene("good");
		UpdateProjectView();
	});

	connect(ui.action_S, &QAction::triggered, [this](){
		mProject->AddScene("good");
		UpdateProjectView();
	});

	connect(ui.planeButton, &QPushButton::clicked, [this](){
		GetEditorLevel()->AddPrimitive(PrimitiveType::Plane);
	});

	connect(ui.icosphereButton, &QPushButton::clicked, [this](){
		GetEditorLevel()->AddPrimitive(PrimitiveType::IcoSphere);
	});

	connect(ui.projectTree, &QTreeWidget::itemDoubleClicked, [this](QTreeWidgetItem *item, int column){
		if (item->parent() != mScenesTreeNode)
			return;

		OpenScene(item->text(0));
	});

	connect(ui.actionNewSceneNode, &QAction::triggered, [this](){
		QString path = QFileDialog::getOpenFileName(this, tr("打开"), "", tr("AGE Mesh (*.AMESH)"));
		if (path.isEmpty())
			return;
		AGE::AGEMeshImporter importer;
		GetEditorLevel()->AddSceneNode(importer.LoadFromFile(path.toStdString().c_str(), true));
	});

	connect(ui.actionNewPhysicsNode, &QAction::triggered, [this](){
		QString path = QFileDialog::getOpenFileName(this, tr("打开"), "", tr("AGE Mesh (*.AMESH)"));
		if (path.isEmpty())
			return;
		AGE::AGEMeshImporter importer;
		GetEditorLevel()->AddPhysicsNode(importer.LoadFromFile(path.toStdString().c_str(), true));
	});

	showMaximized();
}
Пример #2
0
// called from CSimpleFrame::OnRefreshView()
void CSimpleGUIPanel::OnFrameRender() {
    CMainDocument*      pDoc = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    int                 workCount = pDoc->GetSimpleGUIWorkCount();
	CC_STATUS           status;
    bool                isSuspended;

    // OnFrameRender() may be called while SimpleGUI initialization is 
    // in progress due to completion of a periodic get_messages RPC, 
    // causing unintended recursion in CMainDocument::RequestRPC().  
    // Check for that situation here.
    if (pDoc->WaitingForRPC()) return;

    // Workaround for Linux refresh problem
    if (m_irefreshCount < REFRESH_WAIT) {
        ++m_irefreshCount;
        m_taskPanel->UpdatePanel(true);
        return;
    }
	
    if (workCount != m_oldWorkCount) {
        if (workCount < 0) {
            m_projPanel->Hide();
        } else if (m_oldWorkCount == 0) {
            m_projPanel->Show();
        }
        this->Layout();
        ReskinInterface();
    }
    
    if (IsShown()) {
	    if ( pDoc->IsConnected() ) {
        
            // Show Resume or Suspend as appropriate
            pDoc->GetCoreClientStatus(status);

            isSuspended = (RUN_MODE_NEVER == status.task_mode);
            if ((isSuspended != m_bIsSuspended) || (!m_SuspendResumeButton->IsEnabled())) {
                m_bIsSuspended = isSuspended;
                m_SuspendResumeButton->SetLabel(m_bIsSuspended ? m_sResumeString : m_sSuspendString);
                m_SuspendResumeButton->SetToolTip(m_bIsSuspended ? m_sResumeButtonToolTip : m_sSuspendButtonToolTip);
            }
            m_SuspendResumeButton->Enable();
	    } else {
            m_SuspendResumeButton->SetToolTip(wxEmptyString);
            m_SuspendResumeButton->Disable();
        }

		UpdateProjectView();

        if (m_bNewNoticeAlert) {
            wxRect r = m_NoticesButton->GetRect();
            r.Inflate(4, 4);
            RefreshRect(r, m_bNoticesButtonIsRed);
            m_bNoticesButtonIsRed = !m_bNoticesButtonIsRed;
        }


        // State changes can cause the BSG to crash if a dialogue is open.
        // Defer state change until after the dialogue is closed
        if ( dlgOpen ) {
            return;
        }
        
        m_oldWorkCount = workCount;
        
        m_taskPanel->UpdatePanel(false);
    }
}
Пример #3
0
void Editor::ProjectContentChanged()
{
	UpdateTitle();
	UpdateProjectView();
}