/*
=========================
EntityWndProc
=========================
*/
BOOL CALLBACK EntityWndProc(
    HWND hwndDlg,	// handle to dialog box
    UINT uMsg,		// message
    WPARAM wParam,	// first message parameter
    LPARAM lParam)	// second message parameter
{
	RECT	rc;

	GetClientRect(hwndDlg, &rc);

    switch (uMsg)
    {

      case WM_CHAR :
      {
        char c = toupper(LOWORD(wParam));
        if (c == 'N')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_ENTITY, 0);
        else
        if (c == 'O')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_CONSOLE, 0);
        else
        if (c == 'T')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_TEXTURE, 0);
        else
			    DefWindowProc (hwndDlg, uMsg, wParam, lParam);
        break;
      }

	case WM_SIZE:

			DefWindowProc (hwndDlg, uMsg, wParam, lParam);
      break;

  case WM_DESTROY:
      SaveWindowPlacement(g_qeglobals.d_hwndEntity, "EntityWindowPlace");
      DefWindowProc(hwndDlg, uMsg, wParam, lParam);
      break;

	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO	lpmmi;

			lpmmi = (LPMINMAXINFO) lParam;
			lpmmi->ptMinTrackSize.x = 320;
			lpmmi->ptMinTrackSize.y = 700;
		}
		return 0;

	case WM_WINDOWPOSCHANGING:
		{
			LPWINDOWPOS	lpwp;
			lpwp = (LPWINDOWPOS) lParam;

			DefWindowProc (hwndDlg, uMsg, wParam, lParam);

			lpwp->flags |= SWP_NOCOPYBITS;
			SizeEntityDlg(lpwp->cx-8, lpwp->cy-32);
			return 0;

		}
		return 0;


	case WM_COMMAND: 
		switch (LOWORD(wParam)) { 

    case IDC_BTN_ASSIGNSOUND:
      AssignSound();
      break;

    case IDC_BTN_ASSIGNMODEL:
      AssignModel();
      break;

		case IDC_E_DELPROP:
			DelProp();
			SetFocus (g_qeglobals.d_hwndCamera);
			break;

		case IDC_E_0:
			SetKeyValue (edit_entity, "angle", "360");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_45:
			SetKeyValue (edit_entity, "angle", "45");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_90:
			SetKeyValue (edit_entity, "angle", "90");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_135:
			SetKeyValue (edit_entity, "angle", "135");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_180:
			SetKeyValue (edit_entity, "angle", "180");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_225:
			SetKeyValue (edit_entity, "angle", "225");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_270:
			SetKeyValue (edit_entity, "angle", "270");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_315:
			SetKeyValue (edit_entity, "angle", "315");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_UP:
			SetKeyValue (edit_entity, "angle", "-1");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_DOWN:
			SetKeyValue (edit_entity, "angle", "-2");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;

    case IDC_BTN_HIDE:
      ::PostMessage(g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_CAMERATOGGLE, 0);
      break;

		case IDC_CHECK1:
		case IDC_CHECK2:
		case IDC_CHECK3:
		case IDC_CHECK4:
		case IDC_CHECK5:
		case IDC_CHECK6:
		case IDC_CHECK7:
		case IDC_CHECK8:
		case IDC_CHECK9:
		case IDC_CHECK10:
		case IDC_CHECK11:
		case IDC_CHECK12:
		case IDC_CHECK13:
		case IDC_CHECK14:
		case IDC_CHECK15:
		case IDC_CHECK16:
		case IDC_CHECK17:
		case IDC_CHECK18:
		case IDC_CHECK19:
		case IDC_CHECK20:
		case IDC_CHECK21:
			GetSpawnFlags();
			SetFocus (g_qeglobals.d_hwndCamera);
			break;


		case IDC_E_PROPS: 
			switch (HIWORD(wParam))
			{ 
			case LBN_SELCHANGE:

				EditProp();
				return TRUE; 
			}
			break;

		case IDC_E_LIST: 
	   
			switch (HIWORD(wParam)) { 
			
			case LBN_SELCHANGE: 
			{
				int iIndex;
				eclass_t *pec;
				
				iIndex = SendMessage(hwndEnt[EntList], LB_GETCURSEL, 0, 0);	
				pec = (eclass_t *)SendMessage(hwndEnt[EntList], LB_GETITEMDATA, 
						iIndex, 0); 
			
				UpdateSel(iIndex, pec);

				return TRUE; 
				break; 
			}

			case LBN_DBLCLK: 
				CreateEntity ();
				SetFocus (g_qeglobals.d_hwndCamera);
				break; 
			} 
            break; 


            default: 
              return DefWindowProc( hwndDlg, uMsg, wParam, lParam ); 
        } 

		return 0;
	}

    return DefWindowProc (hwndDlg, uMsg, wParam, lParam);
}
Beispiel #2
0
EntityWindow::EntityWindow(EditorWidget *editor, EntityType type, EntityWindowType windowType)
{
    if(!editor->levelOpen)
    {
        close();
        QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
        return;
    }

    this->editor = editor;

    QGridLayout* gLayout = new QGridLayout(this);
    QLabel* nameLabel = new QLabel(QString("Name:"));
    QLabel* tileLabel = new QLabel(QString("Tile:"));
    QLabel* paramLabel = new QLabel(QString("Function:"));
    QLabel* tilesetLabel = new QLabel(QString("Tileset Name:"));
    QLabel* xLabel = new QLabel(QString("Texture Region X:"));
    QLabel* yLabel = new QLabel(QString("Texture Region Y:"));
    QLabel* twLabel = new QLabel(QString("Texture Region Width:"));
    QLabel* thLabel = new QLabel(QString("Texture Region Height:"));
    QLabel* wLabel = new QLabel(QString("Width:"));
    QLabel* hLabel = new QLabel(QString("Height:"));
    QLabel* oxLabel = new QLabel(QString("Origin X:"));
    QLabel* oyLabel = new QLabel(QString("Origin Y:"));
    nameBox = new QLineEdit();
    tilesetBox = new QComboBox();

    int textureNameCount = editor->data.configuration.textureNames.size();
    for(int i = 0; i < textureNameCount; i++)
    {
        tilesetBox->addItem(QString(editor->data.configuration.textureNames[i].c_str()));
    }
    valueBox = Tools::NewSpinBox(0);
    paramBox = Tools::NewSpinBox(0);
    tXBox = Tools::NewSpinBox(INT_MIN); tYBox = Tools::NewSpinBox(INT_MIN);
    tWBox = Tools::NewSpinBox(INT_MIN); tHBox = Tools::NewSpinBox(INT_MIN);
    wBox = Tools::NewSpinBox(INT_MIN); hBox = Tools::NewSpinBox(INT_MIN);
    oxBox = Tools::NewSpinBox(INT_MIN); oyBox = Tools::NewSpinBox(INT_MIN);
    QPushButton* okButton = new QPushButton(QString("OK"));
    QPushButton* cancelButton = new QPushButton(QString("Cancel"));

    gLayout->addWidget(nameLabel,0,0);
    gLayout->addWidget(nameBox,0,1);

    connect(cancelButton,SIGNAL(clicked()),this,SLOT(FullClose()));

    int row = editor->window->manager->entityList->selectionModel()->currentIndex().row();
    int bottomLayoutRow = 3;

    switch(type)
    {
    case Tiles:
        tilePreview = new TilePreviewWidget(editor);

        gLayout->addWidget(tileLabel,1,0);
        gLayout->addWidget(valueBox,1,1);
        gLayout->addWidget(paramLabel,2,0);
        gLayout->addWidget(paramBox,2,1);
        gLayout->addWidget(tilePreview,3,0);
        bottomLayoutRow = 4;

        connect(valueBox, SIGNAL(valueChanged(int)), tilePreview, SLOT(SetTileIndex(int)));
        break;

    case Props:
        gLayout->addWidget(tilesetLabel,0,2);
        gLayout->addWidget(tilesetBox,0,3);
        gLayout->addWidget(xLabel,1,0);
        gLayout->addWidget(tXBox,1,1);
        gLayout->addWidget(yLabel,1,2);
        gLayout->addWidget(tYBox,1,3);
        gLayout->addWidget(twLabel,2,0);
        gLayout->addWidget(tWBox,2,1);
        gLayout->addWidget(thLabel,2,2);
        gLayout->addWidget(tHBox,2,3);
        gLayout->addWidget(wLabel,3,0);
        gLayout->addWidget(wBox,3,1);
        gLayout->addWidget(hLabel,3,2);
        gLayout->addWidget(hBox,3,3);
        gLayout->addWidget(oxLabel,4,0);
        gLayout->addWidget(oxBox,4,1);
        gLayout->addWidget(oyLabel,4,2);
        gLayout->addWidget(oyBox,4,3);
        bottomLayoutRow = 5;
        break;

    case Sprites:
        bottomLayoutRow = 1;
        break;
    }

    switch(windowType)
    {
    case New:
        switch(type)
        {
        case Tiles: connect(okButton,SIGNAL(clicked()),this,SLOT(CreateTile())); break;
        case Props: connect(okButton,SIGNAL(clicked()),this,SLOT(CreateProp())); break;
        case Sprites: connect(okButton,SIGNAL(clicked()),this,SLOT(CreateSprite())); break;
        case Textures: connect(okButton,SIGNAL(clicked()),this,SLOT(CreateTexture())); break;
        case Polygons: connect(okButton,SIGNAL(clicked()),this,SLOT(CreatePolygon())); break;
        }
        break;
    case Edit:
        switch(type)
        {
        case Tiles:
            SetEditTileValues(row);
            connect(okButton,SIGNAL(clicked()),this,SLOT(EditTile()));
            break;
        case Props:
            SetEditPropValues(row);
            connect(okButton,SIGNAL(clicked()),this,SLOT(EditProp()));
            break;
        case Sprites:
            nameBox->setText(QString(editor->data.configuration.spriteDefinitions[row].name.c_str()));
            connect(okButton,SIGNAL(clicked()),this,SLOT(EditSprite()));
            break;
        case Textures:
            nameBox->setText(QString(editor->data.configuration.textureNames[row].c_str()));
            connect(okButton,SIGNAL(clicked()),this,SLOT(EditTexture()));
            break;
        case Polygons:
            nameBox->setText(QString(editor->data.configuration.polygonDefinitions[row].name.c_str()));
            connect(okButton,SIGNAL(clicked()),this,SLOT(EditPolygon()));
            break;
        }
        break;
    }

    gLayout->addWidget(okButton,bottomLayoutRow,0);
    gLayout->addWidget(cancelButton,bottomLayoutRow,1);

}