Results 1 to 11 of 11

Thread: MapName

  1. #1

    Default MapName

    Why it dosen't work when I press Esc ?
    where is the problem ?


    Code:
    class TPSHUD extends HUD;
    
    var config string             MapName;
    var TPSGFx_QuickMenu quickMovie;
    var bool           bInventoryIsLocked;
     
    
    exec function toggleQuickMenu()
    {
    	
    if (MapName == "TPSLevel_Test01" )
    {
    	
    	if ( quickMovie != none && quickMovie.bMovieIsOpen )
    	{
    		quickMovie.PlayCloseAnimation();
    	}
    	else
    	{
    		if( quickMovie == None )
    		{
    			quickMovie = new class'TPSGFx_QuickMenu';
    			quickMovie.MovieInfo = SwfMovie'MainMenu.MainMenuE01';
    			quickMovie.bEnableGammaCorrection = false;
    			quickMovie.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
    			quickMovie.SetTimingMode(TM_Real);
    			quickMovie.SetViewScaleMode(SM_NoScale);
    		}
    
    		PlayerOwner.SetPause(true);
    
    		quickMovie.Start();
    	}
    }
    
    
    if (MapName == "TPSLevel_Test02" )
    {
    	
    	if ( quickMovie != none && quickMovie.bMovieIsOpen )
    	{
    		quickMovie.PlayCloseAnimation();
    	}
    	else
    	{
    		if( quickMovie == None )
    		{
    			quickMovie = new class'TPSGFx_QuickMenu';
    			quickMovie.MovieInfo = SwfMovie'MainMenu.MainMenuE02';
    			quickMovie.bEnableGammaCorrection = false;
    			quickMovie.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
    			quickMovie.SetTimingMode(TM_Real);
    			quickMovie.SetViewScaleMode(SM_NoScale);
    		}
    
    		PlayerOwner.SetPause(true);
    
    		quickMovie.Start();
    	}
    }
    }
    Last edited by foad.torfi; 07-02-2012 at 04:10 PM.

  2. #2
    MSgt. Shooter Person
    Join Date
    Apr 2012
    Posts
    61

    Default

    I'm not familiar with accessing the MapName, but it seems to me that the MapName variable needs to be initialized. It's just a string and i can't see any code that assigns a value to it.

  3. #3
    MSgt. Shooter Person
    Join Date
    Feb 2010
    Posts
    183

    Default

    Don't try to do it this way. Instead create a simple MapInfo class (Takes like 1 minute) and assign a MapInfo of that class to all of your maps in View -> World Info -> Map Info.

    In your MapInfo you need to have at least one variable of type Int or Bool or even String to indicate which level is this, after you do these, you can easilt access this variable from PlayerController and can do whatever you need to do with it.
    Last edited by farshad12; 07-02-2012 at 06:10 PM.

  4. #4

    Default

    His MapName is a config string, so the value is automatically assigned via an ini-file. In which ini-file it is set to "TPSLevel_Test01" is probably determined in a superior class, because in this TPSHUD class there is no config() specifier in the declaration (inherited from parent class).
    I wouldn't configure MapNames in a HUD config section myself.

    But the question is still, why doesn't it work? Without testing for myself I would say, it's either that the MapNames set in the config file aren't "TPSLevel_Test01", nor "TPSLevel_Test02" or you have no keybinding on ESC for the exec function.

    As for coding style, the two if-statements are somewhat identical. Even if it is for testing purposes, obviously, you could to it in one if-statement: if (MapName == "TPSLevel_Test01" || MapName == "TPSLevel_Test02")
    And if it wasn't for testing, I would go about it in a whole other way.

  5. #5

    Default

    I'm not sure, but shouldn't you throw some "SetPause(false);" in there, too? Maybe so:

    Code:
    if ( quickMovie != none && quickMovie.bMovieIsOpen )
    {
        quickMovie.PlayCloseAnimation();
            PlayerOwner.SetPause(false);
    }
    Last edited by Vaquero; 07-02-2012 at 09:49 PM.

  6. #6

    Default

    Thanks for helping.
    I Want to appear MainMenuE01 when I Press Esc in TPSLevel_Test01 and appear MainMenuE02 when I Press Esc in TPSLevel_Test02.
    Please guide me.

    Code:
    exec function toggleQuickMenu()
    {
    
            Local string MapName;	
    	MapName =WorldInfo.Title;
            MapName =WorldInfo.GetMapName(True);    
    		
    	if (MapName == "TPSLevel_Test01")
    	{
    	if ( quickMovie != none && quickMovie.bMovieIsOpen )
    	{
    		quickMovie.PlayCloseAnimation();
    	}
    	else
    	{
    		if( quickMovie == None )
    		{
    			quickMovie = new class'TPSGFx_QuickMenu';
    			quickMovie.MovieInfo = SwfMovie'MainMenu.MainMenuE01';
    			quickMovie.bEnableGammaCorrection = false;
    			quickMovie.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
    			quickMovie.SetTimingMode(TM_Real);
    			quickMovie.SetViewScaleMode(SM_NoScale);
    		}
    
    		PlayerOwner.SetPause(true);
    
    		quickMovie.Start();
    	}
    	
    	}
            if (MapName == "TPSLevel_Test02")
    	{
            if ( quickMovie != none && quickMovie.bMovieIsOpen )
    	{
    		quickMovie.PlayCloseAnimation();
    	}
    	else
    	{
    		if( quickMovie == None )
    		{
    			quickMovie = new class'TPSGFx_QuickMenu';
    			quickMovie.MovieInfo = SwfMovie'MainMenu.MainMenuE02';
    			quickMovie.bEnableGammaCorrection = false;
    			quickMovie.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
    			quickMovie.SetTimingMode(TM_Real);
    			quickMovie.SetViewScaleMode(SM_NoScale);
    		}
    
    		PlayerOwner.SetPause(true);
    
    		quickMovie.Start();
    	}
    	
    	}
    
    }

  7. #7

    Default

    My reply comes with a warning: I actually haven't tested this at all! (Since it would consume too much of my time.) And I am not that experienced yet to advise you on what would work best in your case.
    The code isn't that different from yours, yet less redundant and I added some more fail safes. I, personally, probably would still do some things different.
    My suggestion would be that you temporarily implement `log macros for debugging purposes at each stage to see where it goes wrong (check the content of MapName, quickmenu.MovieInfo and so on).

    Code:
    exec function toggleQuickMenu()
    {
    
    
        Local string MapName;
    
    
    	// MapName =WorldInfo.Title; // This would give you the localized string! Defined in ...\UDKGame\Localization\INT\YourLocalizationFile.int
        MapName =WorldInfo.GetMapName(True); // This gives you the filename of the map. (I guess...)
    		
    	if ( quickMovie != none && quickMovie.bMovieIsOpen )
    	{
    		quickMovie.PlayCloseAnimation();
    		PlayerOwner.SetPause(false);
    	}
    	else
    	{
    		if( quickMovie == None )
    		{
    			quickMovie = new class'TPSGFx_QuickMenu';
    			if (quickMovie != none)
    			{
    				quickMovie.bEnableGammaCorrection = false;
    				quickMovie.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
    				quickMovie.SetTimingMode(TM_Real);
    				quickMovie.SetViewScaleMode(SM_NoScale);
    				switch(MapName)
    				{
    					case ('TPSLevel_Test01'):
    						quickMovie.MovieInfo = SwfMovie'MainMenu.MainMenuE01';
    						break;
    					case ('TPSLevel_Test02'):
    						quickMovie.MovieInfo = SwfMovie'MainMenu.MainMenuE02';
    						break;
    					default:
    						`log("toggleQuickMenu: No menu for map" @MapName @"available!");
    						break;
    				}
    			}
    		}
    		if (quickMovie.MovieInfo != none)
    		{
    			PlayerOwner.SetPause(true);
    			quickMovie.Start();
    		}
    	}
    }
    And still: Do you have you exec function bound correctly to you ESC-key? You can also test it by typing "toggleQuickMenu" in the console while the game is running.

  8. #8
    Palace Guard
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    3,940

    Default

    You should just `log(MapName) the value before the IF check. To see what it actually contains and go on from there.
    Our Loop, which art in source code, hallowed be thy keyword.
    Thy condition come, thy instruction be done, in RAM as it is in cache.
    Increment us this day our daily counter,
    and forgive us our typos, as we also have forgiven our compilers.
    And lead us not to the nullpointer but deliver us from bugs.
    For thine is the API, the GUI, and the CLI while(true).
    Semicolon;
    Please don't send me questions about how to do something in the UDK via PM. That is better discussed in the forums and we only have limited PM storage.

  9. #9

    Default

    And still: Do you have you exec function bound correctly to you ESC-key?
    Yes,I do
    Code:
    -Bindings=(Name="Escape",Command="toggleQuickMenu")
    Thank you Vaquero very nice code I tried that but it didn't work .

    Quote Originally Posted by Crusha K. Rool View Post
    You should just `log(MapName) the value before the IF check. To see what it actually contains and go on from there.
    how can I `log(MapName) ?
    Last edited by foad.torfi; 07-04-2012 at 03:50 AM.

  10. #10
    Prisoner 849
    Join Date
    Jan 2010
    Posts
    901

    Default

    before if(MapName == ....

    put `log(MapName);

    run it,
    check the log.

  11. #11

    Default

    Quote Originally Posted by thommie View Post
    before if(MapName == ....

    put `log(MapName);

    run it,
    check the log.
    Thank you very much my Problem is solved .

    Crusha K. Rool and Vaquero thanks alot for helping .
    Last edited by foad.torfi; 07-04-2012 at 05:47 AM.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.