Announcement

Collapse
No announcement yet.

Some Pesky Code...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Some Pesky Code...

    I removed the default properties and other functions since I dont think that has anything to do with it. I used to get a type mismatch for the underlined code, then I restarted the code from scratch and now I get:

    F:\UT2004\DragonRiderRPG\Classes\RPGAdmin_Menu.uc( 11) : Error, Cast from 'GUITabPanel' to 'RPGAdmin_PlayerList' will always fail

    I'm not good with GUI code, though I've come a long way, its still bugged out every time I make or edit any dialog/gui elements. I finally went through the trouble to just use the premade Admin console as a template and I get problems I cant fix, I should have just made it from scratch and spent more hours.

    Help much appreciated!

    -DragonRider

    Code:
    class RPGAdmin_Menu extends UT2K3GUIPage;
    
    var GUITabControl TabC;
    var RPGAdmin_PlayerList PlayerList;
    
    function InitComponent(GUIController MyController, GUIComponent MyOwner)
    {
     	Super.InitComponent(MyController, MyOwner);
    
        TabC = GUITabControl(Controls[5]);
    	PlayerList = RPGAdmin_PlayerList(TabC.AddTab("Reset","DragonRiderRPG.RPGAdmin_TabReset",,"Reset RPG Player",true));
    	PlayerList = RPGAdmin_PlayerList(TabC.AddTab("Levelup","DragonRiderRPG.RPGAdmin_TabLevel",,"Levelup a RPG Player",false));
    
    	if (PlayerList!=None)
        	PlayerList.ReloadList();
    
    }

    #2
    Long time no see DragonRider.

    Here's some code from a custom GUI menu I made:
    Code:
    class AdminX_Menu extends GUIPage
    	Config( AdminX );
    
    #exec OBJ LOAD FILE=InterfaceContent.utx
    
    // Config Variables
    var( ) config Bool bAutoLogIn;
    var( ) config String adminName;
    var( ) config String adminPass;
    
    var GUITabControl tabC;
    var Tab_AdminX_PlayerList playerList;
    var Tab_AdminX_Game gamePage;
    var Tab_AdminX_Mutators mutatorList;
    
    function InitComponent( GUIController myController, GUIComponent myOwner )
    {
    	Super.InitComponent( myController, myOwner );
    
    	Log( "AdminX.AdminX_Menu.InitComponent", 'SPDT' );
    	tabC = GUITabControl( Controls[5] );
    	playerList = Tab_AdminX_PlayerList( tabC.AddTab( "Players", "AdminX.Tab_AdminX_PlayerList", , "Player Management", True ) );
    	gamePage = Tab_AdminX_Game( tabC.AddTab( "Game & Maps", "AdminX.Tab_AdminX_Game", , "Game Type and Map selection", True ) );
    	mutatorList = Tab_AdminX_Mutators( tabC.AddTab( "Mutators", "AdminX.Tab_AdminX_Mutators", , "Mutator Management", True ) );
    
    	gamePage.OnChangeGameType = ChangeGameType;
    
    	if( playerList != None )
    		playerList.ReloadList( );
    
    	tabC.ActivateTabByName( "Players", True );
    }
    From the error you're getting it seems that RPGAdmin_PlayerList is not subclassed from GUITabPanel, so when the compiler tries to do its stuff it gets confused.  All the tabs I've added in the above code are subclassed from GUITabPanel, and it all works sweetly.

    ****************************

    Did you ever finish Mega Stuff?  I spotted a fault with the last code I ever sent you, and have been adding to it ever since.  I can send you the new revision of the project if you like.

    Comment


      #3
      I have it packed away in the deep dark confines of my UT2k3 folder. Right now I've been modifying Mysterials RPG as you can see from the name of the class.

      So far I have added a level cap option, a option for the max amount of artifact monsters you can summon, and am working on a admin console to reset a single player or level them up or modify their stats ingame so you can penalize them for breaking rules or reward them for doing something you like.

      Going off to change the class right now, in a few minutes I'll reply again and tell ya' if it worked or not... If not I guess its to be scrapped again at least this one file and work off of yours or from scratch, thing gets annoying quick when every time you try to work around a problem another one of the same type happenes.

      Comment


        #4
        Nope, it still is bringing up the same error. I changed the other two Tab controls and the main window to it one at a time and every time no matter the combination it was still the same.

        If you don't have another bright idea I'm going to stop monitoring the forum constantly today and just try again later.

        Thanks for your help bud!

        Comment


          #5
          There's no need to keep tabs on the forum, just keep checking your email every now and then.  You should be subscribed to this thread so will get a mail when a new reply is posted.  That's what I do when waiting for people to get back to me with more information.

          As for the coding problem: look again at the magical code of the Adster (I was just chatting to my brother and said this phrase out loud to him and it sounded funny, that's why I wrote it here).  When I declare each tab it looks like this:
          Code:
          var Tab_AdminX_PlayerList playerList;
          var Tab_AdminX_Game gamePage;
          var Tab_AdminX_Mutators mutatorList;
          These are all custom classes of mine.  When I actually add then to the tab control it looks like this:
          Code:
          	playerList = Tab_AdminX_PlayerList( tabC.AddTab( "Players", "AdminX.Tab_AdminX_PlayerList", , "Player Management", True ) );
          	gamePage = Tab_AdminX_Game( tabC.AddTab( "Game & Maps", "AdminX.Tab_AdminX_Game", , "Game Type and Map selection", True ) );
          	mutatorList = Tab_AdminX_Mutators( tabC.AddTab( "Mutators", "AdminX.Tab_AdminX_Mutators", , "Mutator Management", True ) );
          So if you change your code to look like this it should work correctly:
          Code:
          class RPGAdmin_Menu extends UT2K3GUIPage;
          
          	var GUITabControl TabC;
          	var RPGAdmin_TabReset PlayerList;
          	var RPGAdmin_TabLevel LevelUp; // Don't know what you called this so I guessed. :)
          
          function InitComponent( GUIController myController, GUIComponent myOwner )
          {
          	Super.InitComponent( myController, myOwner );
          	TabC = GUITabControl( Controls[5] );
          	PlayerList = RPGAdmin_TabReset( TabC.AddTab( "Reset", "DragonRiderRPG.RPGAdmin_TabReset", , "Reset RPG Player", True ) );
          	LevelUp = RPGAdmin_TabLevel( TabC.AddTab( "Levelup", "DragonRiderRPG.RPGAdmin_TabLevel", , "Levelup a RPG Player" , False ) );
          
          	if( PlayerList!=None )
          		PlayerList.ReloadList( );
          }
          Give it a bash and let me know how it turns out for you.

          Comment


            #6
            that error always has to do with the data types youre working with. in this case, youre likely trying to cast a type to another that that isnt compatible (a tab page to a button, for instance). as a general rule, type casting only works along the class heirarchy, up or down, i believe.

            Comment


              #7
              Okay, THAT page compiled now when I did that (make each tab a seperate variable), but now the page that I call as a tab is saying all the variables are type mismatch LOL

              I'll fix it though, don't think I need help for THAT :haha:

              Thanks for the help, for some reason I didn't think that using 3 different variables for one set of tabs would work, my logic made me think that it would create seperate groups for each tab then...

              Comment

              Working...
              X