[fixed]Get Level to Display in ui.java

Results 1 to 5 of 5
  1. #1
    Enthusiast 2lifetodeath is offline
    MemberRank
    Sep 2009 Join Date
    38Posts

    thumbs up [fixed]Get Level to Display in ui.java

    I have been trying for about 5 hours to get the Trainer level of your Player to display in the HUD because I am working on a new HUD to release. I tried about the same methods as the "getmoney" like how the money is updated when the game is loaded. The problem I am having is that the settext that loads is -1, which is the assigned var at the initial update. when i go and buy a pokeball or do anything to cause the update again. it will finally update to the correct trainer level. I used mainly UI.java and copied the get money methods. then changed them to the getTrainerLevel and changed the location display.

    If anyone knows how to make the trainer level display correctly, that would be awesome! :D
    BTW: i did try the same method as the Dialogbox with the stats of the character, also came out as -1, while the stat dialog came out as the correct character level.
    Last edited by 2lifetodeath; 22-04-12 at 06:22 AM.


  2. #2
    Ω -DefaulT is offline
    MemberRank
    Aug 2006 Join Date
    Emerald CityLocation
    1,429Posts

    Re: Get Level to Display in ui.java

    ill giveu a hint;

    Trainer level:
    T-Exp * 1.25 + 0.3333

  3. #3
    Enthusiast 2lifetodeath is offline
    MemberRank
    Sep 2009 Join Date
    38Posts

    Re: Get Level to Display in ui.java

    Quote Originally Posted by -DefaulT View Post
    ill giveu a hint;

    Trainer level:
    T-Exp * 1.25 + 0.3333
    No, Sorry, that Didn't work :(

    Here is what I did.

    In UI.java in the client.

    below "this.add(m_moneyLabel);" I added.
    Code:
    		// Trainer data labels
    		m_trainerLabel.setText("Wait");
    		m_trainerLabel.pack();
    		m_trainerLabel.setLocation(110, 6);
    		m_trainerLabel.setVisible(true);
    		m_trainerLabel.setFont(GameClient.getFontLarge());
    		m_trainerLabel.setForeground(new Color(255, 255, 255));
    		this.add(m_trainerLabel);
    //
    Then in the Method that starts with public void update(boolean money...etc

    in the first IF statement I added. This below "m_moneyLabel.pack();"
    Code:
        			m_trainerLabel.setText(""+(GameClient.getInstance().getOurPlayer().getTrainerLevel()));
    				m_trainerLabel.pack();
    :( it changes from "wait" to "-1" then when I goto buy a pokeball it updates to "25"<-My Level. I cant get it to loop it correctly to make it update until it is no longer -1. :)
    ----------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------
    Oh! nevermind, i figured it out. by adding 2 methods. I added.
    this to the bottom on Ui.java.

    Code:
    /**
    	 * Returns the level
    	 * @return the level
    	 */
    	public int getlevel(){
    		return lvl;
    	}
    	
    	/**
    	 * Sets the server version to be displayed
    	 * @param lvl
    	 */
    	public void setCorrectTrainerlevel(int lvl) {
    		m_trainerLabel.setText(" "+ lvl);
    		m_trainerLabel.pack();
    	}
    then I went to do the TcpProtocolHandler.java and added in case 't':
    Code:
    					GameClient.getInstance().getUi().setCorrectTrainerlevel(Integer.parseInt(message.substring(3)));
    before the break;

    Then i went back to the Update method I mentioned earlier in Ui.java and went to double check that the first if is

    Code:
        			m_moneyLabel.setText("$" + String.valueOf(GameClient.getInstance().getOurPlayer().getMoney()));	
        			m_moneyLabel.pack();
        			m_trainerLabel.setText(" "+GameClient.getInstance().getOurPlayer().getTrainerLevel());
        			m_trainerLabel.pack();

    and there you have it!

  4. #4
    Ω -DefaulT is offline
    MemberRank
    Aug 2006 Join Date
    Emerald CityLocation
    1,429Posts

    Re: [fixed]Get Level to Display in ui.java

    i was just giving u it as a hint so u could search the java and find where it handles the trainer level.
    To lead u in the right direction.

  5. #5
    Enthusiast 2lifetodeath is offline
    MemberRank
    Sep 2009 Join Date
    38Posts

    Re: [fixed]Get Level to Display in ui.java

    the hint wasn't helpful. I just figured it out by looking at server rev and following how the rev updated in the tcpprotocolhandler. But your reply motivated me to give it a second try.
    Posted via Mobile Device



Advertisement