Example #1
0
void InitApp() {   
    dprintf("rawr\n");    

    srand(UINT(time(NULL)));

    g_pGameRoot = new CGameRoot();

    g_pGameRoot->AssignWorldFile(LEVEL_TO_LOAD);
    g_pGameRoot->AssignModelSetFile(MODEL_SET_TO_LOAD);
    g_pGameRoot->AssignCharacterSetFile(CHAR_SET_TO_LOAD);
    g_pGameRoot->AssignSpriteAnimationSetFile(SPRITE_SET_TO_LOAD);

    g_pGameRoot->LoadMasterServersFile(MASTER_SERVERS_TO_LOAD);

    // Initialize dialogs
    g_SettingsDlg.Init( &g_DialogResourceManager );
    g_HUD.Init( &g_DialogResourceManager );
    g_UI.Init( &g_DialogResourceManager );

    // Set up HUD
    g_HUD.SetCallback( OnGUIEvent ); int iY = 0; 
    g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 0, iY, 125, 22 );    
    g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 0, iY += 24, 125, 22, VK_F2 );

    // Set up UI
    g_UI.SetCallback( OnGUIEvent ); iY = 0;
    CDXUTEditBox *pEditBox;
    g_UI.AddEditBox( IDC_FILEHEIGHTMAP, L"rawr", 5, iY, 210, 20, false, &pEditBox );
    if( pEditBox )
    {
        pEditBox->SetBorderWidth( 1 );
        pEditBox->SetSpacing( 2 );        
    }
    g_UI.AddButton( IDC_LOADHEIGHTMAP, L"Load HeightMap", 0, iY += 24, 100, 22 );    
}
Example #2
0
//--------------------------------------------------------------------------------------
// Initialize the app 
//--------------------------------------------------------------------------------------
void InitApp()
{
	camera = new CCamera;
	manipulator = new CManipulator;


    g_SettingsDlg.Init( &g_DialogResourceManager );
    g_HUD.Init( &g_DialogResourceManager );
    g_SampleUI.Init( &g_DialogResourceManager );



	//g_HUD
    g_HUD.SetCallback( OnGUIEvent );

    g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 5, 10, 125, 22, VK_F12 );

	//fonts
	g_HUD.SetFont( 1, L"Arial", 20, FW_BOLD );
	g_HUD.SetFont( 2, L"Arial", 16, FW_NORMAL );

	g_HUD.AddEditBox( IDC_NEWFILE, L"testconfig.ini", 150, 10, 120, 30 );
	g_HUD.AddButton( IDC_NEWFILE_BTN, L"New", 280, 15, 60, 20);
	g_HUD.AddEditBox( IDC_LOADFILE, L"testconfig.ini", 150, 40, 120, 30 );
	g_HUD.AddButton( IDC_LOADFILE_BTN, L"Load", 280, 45, 60, 20);
	g_HUD.AddEditBox( IDC_SAVEFILE, L"testconfig.ini", 150, 70, 120, 30 );
	g_HUD.AddButton( IDC_SAVEFILE_BTN, L"Save", 280, 75, 60, 20);

	g_HUD.AddEditBox( IDC_CMD, L"", 5, 5, 300, 30 );
	g_HUD.AddStatic( IDC_STATIC7, L"status", 5, 5, 300, 30 );
	g_HUD.GetStatic( IDC_STATIC7 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_HUD.GetStatic( IDC_STATIC7 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_HUD.GetStatic( IDC_STATIC7 )->GetElement(0)->iFont = 2;

	//g_SampleUI
    g_SampleUI.SetCallback( OnGUIEvent ); int iY = 10;
	g_SampleUI.SetVisible(false);
	
	//fonts
	g_SampleUI.SetFont( 1, L"Arial", 20, FW_BOLD );
	g_SampleUI.SetFont( 2, L"Arial", 16, FW_NORMAL );
	
	g_SampleUI.AddStatic( IDC_OBJNAME, L"Pick object", 0, 0, 200, 30 );
	g_SampleUI.GetStatic( IDC_OBJNAME )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_OBJNAME )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_OBJNAME )->GetElement(0)->iFont = 1;

	g_SampleUI.AddStatic( IDC_STATIC7, L"angleX:",210,0,50,30 );
	g_SampleUI.GetStatic( IDC_STATIC7 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC7 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC7 )->GetElement(0)->iFont = 2;

	g_SampleUI.AddStatic( IDC_STATIC8, L"angleY:",260,0,50,30 );
	g_SampleUI.GetStatic( IDC_STATIC8 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC8 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC8 )->GetElement(0)->iFont = 2;

	//width edit box
	g_SampleUI.AddStatic( IDC_STATIC1, L"Width", 0, 50, 200, 30 );
	g_SampleUI.GetStatic( IDC_STATIC1 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC1 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC1 )->GetElement(0)->iFont = 2;
    g_SampleUI.AddEditBox( IDC_WIDTH, L"", 70, 45, 120, 30 );
	g_SampleUI.AddSlider( IDC_WIDTH_SLIDER, 200, 50, 150, 24, 1, 75, 20, false );

	//length edit box
	g_SampleUI.AddStatic( IDC_STATIC2, L"Length", 0, 80, 200, 30 );
	g_SampleUI.GetStatic( IDC_STATIC2 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC2 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC2 )->GetElement(0)->iFont = 2;
    g_SampleUI.AddEditBox( IDC_LENGTH, L"", 70, 75, 120, 30 );
	g_SampleUI.AddSlider( IDC_LENGTH_SLIDER, 200, 80, 150, 24, 1, 400, 100, false );

	//angle restrictions
	g_SampleUI.AddStatic( IDC_STATIC3, L"Angles restrictions", 0, 110, 200, 30 );
	g_SampleUI.GetStatic( IDC_STATIC3 )->GetElement( 0 )->dwTextFormat = DT_LEFT | DT_TOP;
	g_SampleUI.GetStatic( IDC_STATIC3 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC3 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddStatic( IDC_STATIC4, L"X", 20, 130, 200, 30 );
	g_SampleUI.GetStatic( IDC_STATIC4 )->GetElement( 0 )->dwTextFormat = DT_LEFT | DT_TOP;
	g_SampleUI.GetStatic( IDC_STATIC4 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC4 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddStatic( IDC_STATIC5, L"Y", 20, 160, 200, 30 );
	g_SampleUI.GetStatic( IDC_STATIC5 )->GetElement( 0 )->dwTextFormat = DT_LEFT | DT_TOP;
	g_SampleUI.GetStatic( IDC_STATIC5 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC5 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddEditBox( IDC_ANGLE_RESTRICT_XL, L"", 70, 125, 100, 30 );
	g_SampleUI.AddButton( IDC_ANGLE_RESTRICT_XL_BTN, L"A", 170, 130, 22, 22 );
	g_SampleUI.AddEditBox( IDC_ANGLE_RESTRICT_XU, L"", 220, 125, 100, 30 );
	g_SampleUI.AddButton( IDC_ANGLE_RESTRICT_XU_BTN, L"A", 320, 130, 22, 22 );
	g_SampleUI.AddEditBox( IDC_ANGLE_RESTRICT_YL, L"", 70, 155, 100, 30 );
	g_SampleUI.AddButton( IDC_ANGLE_RESTRICT_YL_BTN, L"A", 170, 160, 22, 22 );
	g_SampleUI.AddEditBox( IDC_ANGLE_RESTRICT_YU, L"", 220, 155, 100, 30 );
	g_SampleUI.AddButton( IDC_ANGLE_RESTRICT_YU_BTN, L"A", 320, 160, 22, 22 );


	//add button
	g_SampleUI.AddButton( IDC_ADDCHAIN, L"Add", 15, 200, 100, 22 );
	g_SampleUI.AddButton( IDC_REMOVECHAIN, L"Remove", 115, 200, 100, 22 );

	//offset
	g_SampleUI.AddStatic( IDC_STATIC6, L"Offset", 0, 230, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddEditBox( IDC_OFFSET_X, L"", 70, 225, 80, 30 );
	g_SampleUI.AddEditBox( IDC_OFFSET_Y, L"", 160, 225, 80, 30 );
	g_SampleUI.AddEditBox( IDC_OFFSET_Z, L"", 250, 225, 80, 30 );

	//physical stuff
	g_SampleUI.AddStatic( IDC_STATIC6, L"Displace", 0, 265, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddEditBox(IDC_DISPLACE, L"", 70, 265, 80, 30);

	g_SampleUI.AddStatic( IDC_STATIC6, L"Direction", 0, 305, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddEditBox(IDC_DIRECTION, L"", 70, 305, 80, 30);

	g_SampleUI.AddStatic( IDC_STATIC6, L"Coefficient", 0, 345, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddEditBox(IDC_COEFFICIENT, L"", 70, 345, 80, 30);

	g_SampleUI.AddStatic( IDC_STATIC6, L"Mass", 0, 385, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddEditBox(IDC_MASS, L"", 70, 385, 80, 30);

	g_SampleUI.AddStatic( IDC_STATIC6, L"Tilt", 0, 425, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddCheckBox( IDC_TILT, L"", 60, 425, 30, 30 );

	g_SampleUI.AddStatic( IDC_STATIC6, L"Pressure", 100, 425, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddCheckBox( IDC_PRESSURE, L"", 160, 425, 30, 30 );

	g_SampleUI.AddStatic( IDC_STATIC6, L"Laser", 200, 425, 70, 30 );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement( 0 )->dwTextFormat = DT_LEFT;
	g_SampleUI.GetStatic( IDC_STATIC6 )->SetTextColor( D3DCOLOR_ARGB( 255, 220, 220, 220 ) );
	g_SampleUI.GetStatic( IDC_STATIC6 )->GetElement(0)->iFont = 2;
	g_SampleUI.AddCheckBox( IDC_LASER, L"", 260, 425, 30, 30 );
}
Example #3
0
//--------------------------------------------------------------------------------------
// Initialize the app 
//--------------------------------------------------------------------------------------
void InitApp()
{
    // Initialize dialogs
    g_SettingsDlg.Init( &g_DialogResourceManager );
    g_HUD.Init( &g_DialogResourceManager );
    g_SampleUI.Init( &g_DialogResourceManager );

    g_HUD.SetCallback( OnGUIEvent ); int iY = 10;
    g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 35, iY, 125, 22 );
    g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", 35, iY += 24, 125, 22 );
    g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 35, iY += 24, 125, 22, VK_F2 );

    g_SampleUI.SetCallback( OnGUIEvent );

    g_SampleUI.SetFont( 1, L"Comic Sans MS", 24, FW_NORMAL );
    g_SampleUI.SetFont( 2, L"Courier New", 16, FW_NORMAL );

    // Static
    g_SampleUI.AddStatic( IDC_STATIC, L"This is a static control.", 0, 0, 200, 30 );
    g_SampleUI.AddStatic( IDC_OUTPUT,
                          L"This static control provides feedback for your action.  It will change as you interact with the UI controls.", 20, 50, 620, 300 );
    g_SampleUI.GetStatic( IDC_OUTPUT )->SetTextColor( D3DCOLOR_ARGB( 255, 255, 0, 0 ) ); // Change color to red
    g_SampleUI.GetStatic( IDC_STATIC )->SetTextColor( D3DCOLOR_ARGB( 255, 0, 255, 0 ) ); // Change color to green
    g_SampleUI.GetControl( IDC_OUTPUT )->GetElement( 0 )->dwTextFormat = DT_LEFT | DT_TOP | DT_WORDBREAK;
    g_SampleUI.GetControl( IDC_OUTPUT )->GetElement( 0 )->iFont = 2;
    g_SampleUI.GetControl( IDC_STATIC )->GetElement( 0 )->dwTextFormat = DT_CENTER | DT_VCENTER | DT_WORDBREAK;

    // Buttons
    g_SampleUI.AddButton( IDC_ENABLEIME, L"Enable (I)ME", 30, 390, 80, 35, L'I' );
    g_SampleUI.AddButton( IDC_DISABLEIME, L"Disable I(M)E", 30, 430, 80, 35, L'M' );

    // Edit box
    g_SampleUI.AddEditBox( IDC_EDITBOX1, L"Edit control with default styles. Type text here and press Enter", 20, 440,
                           600, 32 );

    // IME-enabled edit box
    CDXUTIMEEditBox* pIMEEdit;
    CDXUTIMEEditBox::InitDefaultElements( &g_SampleUI );
    if( SUCCEEDED( CDXUTIMEEditBox::CreateIMEEditBox( &g_SampleUI, IDC_EDITBOX2,
                                                      L"IME-capable edit control with custom styles. Type and press Enter", 20, 390, 600, 45, false, &pIMEEdit ) ) )
    {
        g_SampleUI.AddControl( pIMEEdit );
        pIMEEdit->GetElement( 0 )->iFont = 1;
        pIMEEdit->GetElement( 1 )->iFont = 1;
        pIMEEdit->GetElement( 9 )->iFont = 1;
        pIMEEdit->GetElement( 0 )->TextureColor.Init( D3DCOLOR_ARGB( 128, 255, 255, 255 ) );  // Transparent center
        pIMEEdit->SetBorderWidth( 7 );
        pIMEEdit->SetTextColor( D3DCOLOR_ARGB( 255, 64, 64, 64 ) );
        pIMEEdit->SetCaretColor( D3DCOLOR_ARGB( 255, 64, 64, 64 ) );
        pIMEEdit->SetSelectedTextColor( D3DCOLOR_ARGB( 255, 255, 255, 255 ) );
        pIMEEdit->SetSelectedBackColor( D3DCOLOR_ARGB( 255, 40, 72, 72 ) );
    }

    // Slider
    g_SampleUI.AddSlider( IDC_SLIDER, 200, 450, 200, 24, 0, 100, 50, false );

    // Checkbox
    g_SampleUI.AddCheckBox( IDC_CHECKBOX, L"This is a checkbox with hotkey. Press 'C' to toggle the check state.",
                            170, 450, 350, 24, false, L'C', false );
    g_SampleUI.AddCheckBox( IDC_CLEAREDIT,
                            L"This checkbox controls whether edit control text is cleared when Enter is pressed. (T)",
                            170, 460, 450, 24, false, L'T', false );

    // Combobox
    CDXUTComboBox* pCombo;
    g_SampleUI.AddComboBox( IDC_COMBOBOX, 0, 0, 200, 24, L'O', false, &pCombo );
    if( pCombo )
    {
        pCombo->SetDropHeight( 100 );
        pCombo->AddItem( L"Combobox item (O)", ( LPVOID )0x11111111 );
        pCombo->AddItem( L"Placeholder (O)", ( LPVOID )0x12121212 );
        pCombo->AddItem( L"One more (O)", ( LPVOID )0x13131313 );
        pCombo->AddItem( L"I can't get enough (O)", ( LPVOID )0x14141414 );
        pCombo->AddItem( L"Ok, last one, I promise (O)", ( LPVOID )0x15151515 );
    }

    // Radio buttons
    g_SampleUI.AddRadioButton( IDC_RADIO1A, 1, L"Radio group 1 Amy (1)", 0, 50, 220, 24, false, L'1' );
    g_SampleUI.AddRadioButton( IDC_RADIO1B, 1, L"Radio group 1 Brian (2)", 0, 50, 220, 24, false, L'2' );
    g_SampleUI.AddRadioButton( IDC_RADIO1C, 1, L"Radio group 1 Clark (3)", 0, 50, 220, 24, false, L'3' );

    g_SampleUI.AddRadioButton( IDC_RADIO2A, 2, L"Single (4)", 0, 50, 90, 24, false, L'4' );
    g_SampleUI.AddRadioButton( IDC_RADIO2B, 2, L"Double (5)", 0, 50, 90, 24, false, L'5' );
    g_SampleUI.AddRadioButton( IDC_RADIO2C, 2, L"Triple (6)", 0, 50, 90, 24, false, L'6' );

    // List box
    g_SampleUI.AddListBox( IDC_LISTBOX, 30, 400, 200, 150, 0 );
    for( int i = 0; i < 15; ++i )
    {
        WCHAR wszText[50];
        swprintf_s( wszText, 50, L"Single-selection listbox item %d", i );
        g_SampleUI.GetListBox( IDC_LISTBOX )->AddItem( wszText, ( LPVOID )( size_t )i );
    }
    g_SampleUI.AddListBox( IDC_LISTBOXM, 30, 400, 200, 150, CDXUTListBox::MULTISELECTION );
    for( int i = 0; i < 30; ++i )
    {
        WCHAR wszText[50];
        swprintf_s( wszText, 50, L"Multi-selection listbox item %d", i );
        g_SampleUI.GetListBox( IDC_LISTBOXM )->AddItem( wszText, ( LPVOID )( size_t )i );
    }
}