Ejemplo n.º 1
0
void UnitPlacementButton::MouseUp()
{
#ifndef NON_PLAYABLE
    if( g_app->GetWorld()->GetTimeScaleFactor() == 0 )
    {
        return;
    }
	if( !m_disabled )
	{
		if( !EclGetWindow( "Placement" ) )
		{
            SidePanel *parent = (SidePanel *)m_parent;
            parent->m_mode = SidePanel::ModeUnitPlacement;
			PlacementIconWindow *icon = new PlacementIconWindow( "Placement", m_unitType );
			EclRegisterWindow( icon, m_parent );

			g_app->GetMapRenderer()->m_showTeam[ g_app->GetWorld()->m_myTeamId ] = true;
            if( m_unitType == WorldObject::TypeRadarStation )
            {
                g_app->GetMapRenderer()->m_showRadar = true;
            }
            InfoWindow *info = (InfoWindow *)EclGetWindow("Info");
            if( info )
            {
                info->SwitchInfoDisplay( m_unitType, -1 );
            }
		}
		else
		{
	        EclRemoveWindow( "Placement" );
		}
	}
#endif
}
Ejemplo n.º 2
0
void EclRender ()
{

    bool maximiseRender = false;

    //
    // Render any maximised Window?

    if( strcmp( maximisedWindow, "None" ) != 0 )
    {
        EclWindow *maximised = EclGetWindow( maximisedWindow );
        if( maximised )
        {
            maximised->Render( true );
            maximiseRender = true;
        }
        else
        {
            EclUnMaximise();
        }
    }

    if( !maximiseRender )
    {
        for ( int i = windows.Size() - 1; i >= 0; --i )
        {
            EclWindow *window = windows.GetData(i);
            bool hasFocus = ( strcmp ( window->m_name, windowFocus ) == 0 );
            
            START_PROFILE( window->m_name );
            window->Render( hasFocus );
            END_PROFILE( window->m_name );
        }
    }


    //
    // Render the tooltip

    if( tooltipTimer > 0.0f && tooltipCallback )
    {
        EclWindow *window = EclGetWindow();
        if( window )
        {
            EclButton *button = window->GetButton( EclGetCurrentButton() );
            {
                if( button )
                {
                    float timer = GetHighResTime() - tooltipTimer;
                    tooltipCallback( window, button, timer );
                }
            }
        }
    }
}
void EclRegisterWindow ( EclWindow *window, EclWindow *parent )
{
//    DebugAssert( window );

    if ( EclGetWindow ( window->m_name ) )
    {        
    }

    if( parent && window->m_x == 0 && window->m_y == 0 )
    {
        // We should place the window in a decent location
        int left = screenW / 2 - parent->m_x;
        int above = screenH / 2 - parent->m_y;
        if( left > window->m_w / 2 )    window->m_x = int( parent->m_x + parent->m_w * (float) AppRandom() / (float) APP_RAND_MAX );
        else                            window->m_x = int( parent->m_x - window->m_w * (float) AppRandom() / (float) APP_RAND_MAX );
        if( above > window->m_h / 2 )   window->m_y = int( parent->m_y + parent->m_h * (float) AppRandom() / (float) APP_RAND_MAX );
        else                            window->m_y = int( parent->m_y - window->m_h/2 * (float) AppRandom() / (float) APP_RAND_MAX );
    }

	window->MakeAllOnScreen();
    windows.PutDataAtStart ( window );
    window->Create();
    EclDirtyWindow( window );

}
void LocationEditor::AdvanceModeCameraMount()
{
  	if ( g_inputManager->controlEvent( ControlTileSelect ) )
	{
		CameraAnimSecondaryEditWindow *win = (CameraAnimSecondaryEditWindow*)
												EclGetWindow("editor_cameraanim");
		if (win && win->m_newNodeArmed)
		{
			Vector3 rayStart, rayDir;
			g_app->m_camera->GetClickRay( g_target->X(), 
										  g_target->Y(),
										  &rayStart, &rayDir );
			int mountId = DoesRayHitCameraMount(rayStart, rayDir);
			if (mountId != -1)
			{
				CameraMount *mount = g_app->m_location->m_levelFile->m_cameraMounts[mountId];
				AppDebugAssert(mount);
				
				CameraAnimation *anim = g_app->m_location->m_levelFile->m_cameraAnimations[m_selectionId];
				AppDebugAssert(anim);
				
				CamAnimNode *node = new CamAnimNode;
				node->m_mountName = strdup(mount->m_name);

				anim->m_nodes.PutData(node);

				win->m_newNodeArmed = false;
				win->RemoveButtons();
				win->AddButtons();
			}
		}
	}
}
Ejemplo n.º 5
0
ConnectingWindow::~ConnectingWindow()
{
    if( !EclGetWindow( "Connection Status") )
    {
        g_app->GetClientToServer()->m_synchronising = false;
    }
}
void LocationEditor::AdvanceModeLandFlat()
{
	Vector3 mousePos3D = g_app->m_userInput->GetMousePos3d();

	int newSelectionId = -1;
	if ( g_inputManager->controlEvent( ControlTileSelect ) )
	{
		Vector3 mousePos = g_app->m_userInput->GetMousePos3d();
		newSelectionId = IsPosInFlattenArea(mousePos);
	}

	if (m_selectionId == -1)
	{
		// If there isn't currently any selection, then check for a new one
		if (newSelectionId != -1)
		{
			m_selectionId = newSelectionId;
			m_waitingForRelease = true;
			
			EclWindow *cw = EclGetWindow("editor_landscape");
			AppDebugAssert(cw);
			LandscapeFlattenAreaEditWindow *ew = new LandscapeFlattenAreaEditWindow("Flatten Area", newSelectionId);
			ew->m_w = cw->m_w;
			ew->m_h = 100;
			ew->m_x = 0;
			EclRegisterWindow(ew);
			ew->m_y = cw->m_y - ew->m_h - 10;
		}
	}
	else
	{
		Location *location = g_app->m_location;

		if ( g_inputManager->controlEvent( ControlTileSelect ) )
		{
			if (newSelectionId == m_selectionId)
			{
				// The user "grabs" the landscape at this position
				LandscapeDef *landscapeDef = &(g_app->m_location->m_levelFile->m_landscape);
				LandscapeFlattenArea *areaDef = g_app->m_location->m_levelFile->m_landscape.m_flattenAreas.GetData(m_selectionId);
				m_landscapeGrabX = mousePos3D.x - areaDef->m_centre.x;
				m_landscapeGrabZ = mousePos3D.z - areaDef->m_centre.z;
			}
			else
			{
				// The user has deselected the flatten area
				m_selectionId = newSelectionId;
				m_waitingForRelease = true;
				EclRemoveWindow("Flatten Area");
			}
		}
		else if ( g_inputManager->controlEvent( ControlTileDrag ) )
		{
			// The user "drags" the flatten area around
			LandscapeFlattenArea *areaDef = g_app->m_location->m_levelFile->m_landscape.m_flattenAreas.GetData(m_selectionId);
			areaDef->m_centre.x = mousePos3D.x - m_landscapeGrabX;
			areaDef->m_centre.z = mousePos3D.z - m_landscapeGrabZ;
		}
	}
}
void ScrollBarButton::MouseDown()
{
    if( m_grabOffset > -1 )
    {
        AppDebugAssert( m_scrollBar );
        int pixelsInside = g_target->Y() - ( m_parent->m_y + m_y );
        float fractionInside = (float) pixelsInside / (float) m_h;
        int centreVal = fractionInside * m_scrollBar->m_numRows;
        int desiredVal = centreVal - m_grabOffset;
        m_scrollBar->SetCurrentValue( desiredVal );
    }
    else
    {
        AppDebugAssert( m_scrollBar );
        EclWindow *parent = EclGetWindow( m_scrollBar->m_parentWindow );
        AppDebugAssert( parent );
        int mouseY = g_target->Y();
        int barTop = int( m_parent->m_y + m_y + m_h * (float) m_scrollBar->m_currentValue / (float) m_scrollBar->m_numRows );
        int barEnd = int( m_parent->m_y + m_y + m_h * (float) (m_scrollBar->m_currentValue + m_scrollBar->m_winSize) / (float) m_scrollBar->m_numRows );    
        //if( barEnd >= m_h ) barEnd = m_h-1;
        if( mouseY >= barTop && mouseY <= barEnd )
        {
            m_grabOffset = m_scrollBar->m_winSize * float( mouseY - barTop ) / float( barEnd - barTop );
        }
    }
}
Ejemplo n.º 8
0
void EclRegisterWindow ( EclWindow *window, EclWindow *parent )
{
    
    AppAssert( window );

    if ( EclGetWindow ( window->m_name ) )
    {
        AppReleaseAssert( false, "Window %s already exists", window->m_name );
    }

    if( parent && window->m_x == 0 && window->m_y == 0 )
    {
        // We should place the window in a decent locatiom
        int left = screenW / 2 - parent->m_x;
        int above = screenH / 2 - parent->m_y;
        if( left > window->m_w / 2 )    window->m_x = int( parent->m_x + parent->m_w * (float) rand() / (float) RAND_MAX );
        else                            window->m_x = int( parent->m_x - window->m_w * (float) rand() / (float) RAND_MAX );
        if( above > window->m_h / 2 )   window->m_y = int( parent->m_y + parent->m_h * (float) rand() / (float) RAND_MAX );
        else                            window->m_y = int( parent->m_y - window->m_h/2 * (float) rand() / (float) RAND_MAX );
    }

    if( window->m_x < 0 ) window->m_x = 0;
    if( window->m_y < 0 ) window->m_y = 0;
    if( window->m_x + window->m_w > screenW ) window->m_x = screenW - window->m_w;
    if( window->m_y + window->m_h > screenH ) window->m_y = screenH - window->m_h;

    windows.PutDataAtStart ( window );
    window->Create();

    EclSetCurrentFocus( window->m_name );
}
Ejemplo n.º 9
0
EclWindow *EclGetWindow()
{
    //EclWindow *currentWindow = EclGetWindow( windowFocus );
    //return currentWindow;

    return EclGetWindow( mouseX, mouseY );
}
void ScrollBarButton::MouseUp()
{    
    if( m_grabOffset == -1 )
    {

        AppDebugAssert( m_scrollBar );

        EclWindow *parent = EclGetWindow( m_scrollBar->m_parentWindow );
        AppDebugAssert( parent );

        int barTop = int( parent->m_y + m_y + m_h * (float) m_scrollBar->m_currentValue / (float) m_scrollBar->m_numRows );
        int barEnd = int( parent->m_y + m_y + m_h * (float) (m_scrollBar->m_currentValue + m_scrollBar->m_winSize) / (float) m_scrollBar->m_numRows );    
        if( barEnd >= m_h ) barEnd = m_h-1;

		int mouseY = g_target->Y();

        if( mouseY < barTop )
        {
            m_scrollBar->ChangeCurrentValue( -m_scrollBar->m_winSize );
        }
        else if( mouseY > barEnd )
        {
            m_scrollBar->ChangeCurrentValue( m_scrollBar->m_winSize );
        }

    }
    else
    {
        m_grabOffset = -1;
    }

}
Ejemplo n.º 11
0
void Interface::OpenSetupWindows()
{
    if( !EclGetWindow("Main Menu" ) )
    {
        MainMenu *mainmenu = new MainMenu();
        EclRegisterWindow( mainmenu );
    }
}
void EclRemovePopup ()
{
    if( EclGetWindow( popupWindow ) )
    {
        EclRemoveWindow( popupWindow );
    }
    strcpy( popupWindow, "None" );
}
Ejemplo n.º 13
0
void EclUpdateKeyboard ( int keyCode, bool shift, bool ctrl, bool alt, unsigned char ascii )
{
    EclWindow *currentWindow = EclGetWindow( windowFocus );
    if ( currentWindow )
    {
        currentWindow->Keypress( keyCode, shift, ctrl, alt, ascii );
    }
}
void LocationEditor::AdvanceModeInstantUnit()
{
	Camera *cam = g_app->m_camera;

	int newSelectionId = -1;
	if ( g_inputManager->controlEvent( ControlTileSelect ) ) // TODO: Should be something else?
	{
		Vector3 rayStart, rayDir;
		cam->GetClickRay( g_target->X(), g_target->Y(), &rayStart, &rayDir );
		newSelectionId = DoesRayHitInstantUnit(rayStart, rayDir);
	}

	if (m_selectionId == -1)
	{
		if (newSelectionId != -1)
		{
			m_selectionId = newSelectionId;
			EclWindow *cw = EclGetWindow("editor_instantunits");
			AppDebugAssert(cw);
			InstantUnitEditWindow *ew = new InstantUnitEditWindow("editor_instantuniteditor");
			ew->m_w = cw->m_w;
			ew->m_h = 160;
			ew->m_x = cw->m_x;
			EclRegisterWindow(ew);
			ew->m_y = cw->m_y - ew->m_h - 10;
			m_waitingForRelease = true;
		}
	}
	else 
	{
		if ( g_inputManager->controlEvent( ControlTileSelect ) ) // TODO: Something else?
		{
			if (newSelectionId != m_selectionId)
			{
				m_selectionId = -1;
				EclRemoveWindow("editor_instantuniteditor");
			}
		}
		else if ( g_inputManager->controlEvent( ControlTileDrag ) ) // TODO: Something else?
		{
			InstantUnit *iu = g_app->m_location->m_levelFile->m_instantUnits.GetData(m_selectionId);
			switch (m_tool)
			{
				case ToolMove:
				{
					Vector3 mousePos = g_app->m_userInput->GetMousePos3d();
					iu->m_posX = mousePos.x;
					iu->m_posZ = mousePos.z;
					break;
				}
			}
		}
	}
}
Ejemplo n.º 15
0
void EclUnMaximise ()
{
    EclWindow *w = EclGetWindow( maximisedWindow );
    strcpy( maximisedWindow, "None" );

    if( w )
    {
        w->SetPosition( maximiseOldX, maximiseOldY );
        w->SetSize( maximiseOldW, maximiseOldH );
    }
}
void EclRender ()
{

    bool maximiseRender = false;

    //
    // Render any maximised Window?

    if( strcmp( maximisedWindow, "None" ) != 0 )
    {
        EclWindow *maximised = EclGetWindow( maximisedWindow );
        if( maximised )
        {
            clearDraw ( maximised->m_x, maximised->m_y, maximised->m_w, maximised->m_h );
            maximised->Render( true );
            maximiseRender = true;
        }
        else
        {
            EclUnMaximise();
        }
    }

    if( !maximiseRender )
    {

        //
        // Clear all dirty rectangle areas

        if ( clearDraw )
        {
            for( int i = 0; i < dirtyrects.Size(); ++i )
            {
                DirtyRect *dr = dirtyrects.GetData(i);
                clearDraw ( dr->m_x, dr->m_y, dr->m_width, dr->m_height );
            }
        }

        //
        // Draw all dirty buttons

        for ( int i = windows.Size() - 1; i >= 0; --i )
        {
            EclWindow *window = windows.GetData(i);
            if ( window->m_dirty ) {
                bool hasFocus = ( strcmp ( window->m_name, windowFocus ) == 0 );
                window->Render( hasFocus );
                //window->m_dirty = false;
            }
        }

    }

}
void EclDirtyWindow ( char *name )
{

    EclWindow *window = EclGetWindow(name);
    if ( window )
    {
        EclDirtyWindow( window );
    }
    else
    {
    }
}
// *** Advance
void UserInput::Advance()
{
    START_PROFILE(g_app->m_profiler, "Advance UserInput");

	g_inputManager->Advance();

	if (m_removeTopLevelMenu)
	{
		EclWindow *win = EclGetWindow(LANGUAGEPHRASE("dialog_toolsmenu"));
		if (win)
		{
			EclRemoveWindow(win->m_name);
		}
		m_removeTopLevelMenu = false;
	}

	AdvanceMenus();

    bool modsEnabled = g_prefsManager->GetInt( "ModSystemEnabled", 0 ) != 0;


    if( g_inputManager->controlEvent( ControlGamePause ) )	g_app->m_clientToServer->RequestPause();

//    if (g_keyDeltas[KEY_F2]) DebugKeyBindings::DebugCameraButton();
#ifdef LOCATION_EDITOR
    if( modsEnabled )
    {
        if ( g_inputManager->controlEvent( ControlToggleEditor ) ) DebugKeyBindings::EditorButton();
    }
#endif
//
#ifdef CHEATMENU_ENABLED
    if( g_inputManager->controlEvent( ControlToggleCheatMenu ) ) DebugKeyBindings::CheatButton();
#endif

//
//    if (g_keyDeltas[KEY_F5]) DebugKeyBindings::FPSButton();
//#ifdef PROFILER_ENABLED
//	if (g_keyDeltas[KEY_F10]) DebugKeyBindings::ProfileButton();
//#endif // PROFILER_ENABLED


#ifdef SOUND_EDITOR
    if( modsEnabled )
    {
//        if (g_keyDeltas[KEY_F7]) DebugKeyBindings::SoundStatsButton();
//        if (g_keyDeltas[KEY_F11]) DebugKeyBindings::SoundEditorButton();
//        if (g_keyDeltas[KEY_F9]) DebugKeyBindings::SoundProfileButton();
    }
#endif // SOUND_EDITOR

    END_PROFILE(g_app->m_profiler, "Advance UserInput");
}
Ejemplo n.º 19
0
bool Interface::UsingChatWindow()
{
    EclWindow *currentWindow = EclGetWindow();
    if( currentWindow &&
        stricmp(currentWindow->m_name, "Comms Window") == 0 )
    {
        ChatWindow *chat = (ChatWindow *)currentWindow;
        if( chat->m_typingMessage )
        {
            return true;
        }
    }

    ChatWindow *chat = (ChatWindow *)EclGetWindow("Comms Window");
    if( chat &&
        chat->m_typingMessage )
    {
        return true;
    }

    return false;
}
void EclUnMaximise ()
{
    EclWindow *w = EclGetWindow( maximisedWindow );
    strcpy( maximisedWindow, "None" );

    if( w )
    {
        w->SetPosition( maximiseOldX, maximiseOldY );
        w->SetSize( maximiseOldW, maximiseOldH );
    }

    EclDirtyRectangle( 0, 0, screenW, screenH );
}
Ejemplo n.º 21
0
char *EclGenerateUniqueWindowName( char *name )
{
    static char uniqueName[SIZE_ECLWINDOW_NAME];

    int index = 1;
    strcpy( uniqueName, name );
    while( EclGetWindow( uniqueName ) )
    {
        ++index;
        sprintf( uniqueName, "%s%d", name, index );
    }

    return uniqueName;
}
Ejemplo n.º 22
0
    void MouseUp()
    {
        AlliancesWindow *parent = (AlliancesWindow *)m_parent;
        int teamId = parent->m_teamOrder[m_teamIndex];
        Team *team = g_app->GetWorld()->GetTeam(teamId);
        Team *myTeam = g_app->GetWorld()->GetMyTeam();

        if( team && 
            team != myTeam &&
            !EclGetWindow( "Share Radar" ) )
        {
            EclRegisterWindow( new ShareRadarWindow( teamId ), m_parent );
        }
    }
Ejemplo n.º 23
0
void EclSetWindowSize ( char *name, int w, int h )
{
    EclWindow *window = EclGetWindow(name);
    if ( window )
    {
        window->Remove();
        window->m_w = w;
        window->m_h = h;
        window->Create();
    }
    else
    {
        AppDebugOut( "EclSetWindowSize failed on window %s\n", name );
    }
}
Ejemplo n.º 24
0
void EclSetWindowPosition ( char *name, int x, int y )
{

    EclWindow *window = EclGetWindow(name);
    if ( window )
    {
        window->m_x = x;
        window->m_y = y;
    }
    else
    {
        AppDebugOut( "EclSetWindowPosition failed on window %s\n", name );
    }

}
void EclSetWindowPosition ( char *name, int x, int y )
{

    EclWindow *window = EclGetWindow(name);
    if ( window )
    {
        EclDirtyWindow( window );
        window->m_x = x;
        window->m_y = y;
        EclDirtyRectangle( window->m_x, window->m_y, window->m_w, window->m_h );
    }
    else
    {
    }

}
Ejemplo n.º 26
0
void EclMaximiseWindow ( char *name )
{
    EclUnMaximise();
    EclWindow *w = EclGetWindow( name );
    if( w )
    {
        strcpy( maximisedWindow, name );
        strcpy( mouseDownWindow, name );
        strcpy( windowFocus, name );
        maximiseOldX = w->m_x;
        maximiseOldY = w->m_y;
        maximiseOldW = w->m_w;
        maximiseOldH = w->m_h;
        w->SetPosition( 0, 0 );
        w->SetSize( screenW, screenH );
    }
}
void EclSetWindowSize ( char *name, int w, int h )
{
    EclWindow *window = EclGetWindow(name);
    if ( window )
    {
        window->Remove();
        EclDirtyWindow( window );
        EclDirtyRectangle( window->m_x, window->m_y, window->m_w, window->m_h );
        window->m_w = w;
        window->m_h = h;
        window->Create();
        EclDirtyRectangle( window->m_x, window->m_y, window->m_w, window->m_h );
    }
    else
    {
    }
}
LocationEditor::~LocationEditor()
{
	MainEditWindow *mainWin = (MainEditWindow *)EclGetWindow("editor_mainedit");

	// Remove current tool window
    if( mainWin )
    {
	    if (mainWin->m_currentEditWindow)
	    {
		    EclRemoveWindow(mainWin->m_currentEditWindow->m_name);
		    mainWin->m_currentEditWindow = NULL;
	    }
    }

	// Remove main edit window
	EclRemoveWindow("editor_mainedit");
}
void ScrollBar::Remove()
{
    EclWindow *parent = EclGetWindow( m_parentWindow );
    if( parent )
    {
        char barName[256];
        char upName[256];
        char downName[256];

        sprintf( barName, "%s bar", m_name );
        sprintf( upName, "%s up", m_name );
        sprintf( downName, "%s down", m_name );

        parent->RemoveButton( barName );
        parent->RemoveButton( upName );
        parent->RemoveButton( downName );
    }
}
Ejemplo n.º 30
0
int EclMouseStatus()
{
    EclWindow *mouseWindow = EclGetWindow( mouseX, mouseY );

    bool resizeH = false;
    bool resizeV = false;

    if( mouseWindow && mouseY > mouseWindow->m_y + mouseWindow->m_h - 6 )
    {
        resizeV = true;    
    }

    if( mouseWindow && mouseX > mouseWindow->m_x + mouseWindow->m_w - 6 )
    {
        resizeH = true;
    }

    if( mouseDownBottom ) resizeV = true;
    if( mouseDownRight ) resizeH = true;

    if( resizeH && 
        resizeV )   return EclMouseStatus_ResizeHV;
    if( resizeH )   return EclMouseStatus_ResizeH;
    if( resizeV )   return EclMouseStatus_ResizeV;


    if( mouseWindow ) 
    {
        EclButton *button = mouseWindow->GetButton ( mouseX - mouseWindow->m_x, 
                                                     mouseY - mouseWindow->m_y );

        if( button )
        {
            return EclMouseStatus_InWindow;
        }
        else
        {
            return EclMouseStatus_Draggable;
        }
    }
    
    
    return EclMouseStatus_NoWindow;
}