GUI_MSG_WINDOW_INIT! (1 Viewer)

waeberd

Portal Pro
August 16, 2004
314
1
Fribourg (CH)
One basic question:

My plugin is initialized correctly the first time it is activated (through the GUI_MSG_WINDOW_INIT GuiMessage).

If I go back to the main menu and want to jump into my plugin again, the button is not responding anymore....

To go back, I do the following command:
Code:
GUIWindowManager.ActivateWindow( (int)GUIWindow.Window.WINDOW_HOME);

so I guess that GUI_MSG_WINDOW_INIT is not fired because the window still exists...

What is the right message to catch in this case?
Or is the problem somewhere else (apart from that I'm still a bloody C# rookie! :twisted: )?

Thanks,

Daniel
 

Frodo

Retired Team Member
  • Premium Supporter
  • April 22, 2004
    1,518
    121
    51
    The Netherlands
    Home Country
    Netherlands Netherlands
    why not use:
    Code:
        public override void OnAction(Action action)
        {
          if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)
          {
            GUIWindowManager.PreviousWindow();
            return;
          }
    			
          base.OnAction(action);
    
    }
    
    frodo
     

    waeberd

    Portal Pro
    August 16, 2004
    314
    1
    Fribourg (CH)
    mhhh... didn't help....

    The sequence is: <ENTER> <ESCAPE> <ENTER>

    1) <ENTER>
    Plugin is started because I catch the
    Code:
    public override bool OnMessage(GUIMessage message)
    {
      switch ( message.Message )
      {
        case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
        // init stuff here.....

    2) <ESCAPE>
    Plugin is exited because of the OnActionHandler....
    Code:
    public override void OnAction(Action action) 
    { 
      if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU) 
        { 
          GUIWindowManager.PreviousWindow(); 
          return; 
        } 
        base.OnAction(action); 
    }

    3) <ENTER>
    Nothing happens.....
    What did I forget to be able to re-enter the plugin??

    Thanks a lot & hope it's clear!

    Daniel
     

    Frodo

    Retired Team Member
  • Premium Supporter
  • April 22, 2004
    1,518
    121
    51
    The Netherlands
    Home Country
    Netherlands Netherlands
    and...
    make sure your window id is unique like this:

    Code:
    public class MyPlugin : GUIWindow,  ISetupForm
    {
    	public MyPlugin()
    	{
    		GetID = 8000; //should be unique!!!
    	}
    	
    	public override bool Init()
    	{
                bool bResult = Load(GUIGraphicsContext.Skin + @"\myplugin.xml");
                return bResult;
    	}
    	.....
    }
    make sure that the 8000 is unique. (Each window has its own ID
    and that the exact same ID is also mentioned in your xml file!
    (myplugin.xml in this case)


    Frodo
     

    waeberd

    Portal Pro
    August 16, 2004
    314
    1
    Fribourg (CH)
    frodo said:
    do you call base.OnMessage(msg) also?

    Yes, I do!

    Here's the whole OnAction / OnMessage part - sorry to bug you with this stuff.....

    Code:
        public override void OnAction(Action action)
        {
          if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU) 
          { 
            GUIWindowManager.PreviousWindow(); 
            return; 
          } 
          base.OnAction(action); 
        }
    
        public override bool OnMessage(GUIMessage message)
        {
          switch ( message.Message )
          {
            case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
              // display application list
              base.OnMessage(message);
              DisplayApplications();
              UpdateButtons();
              return true;
          
            case GUIMessage.MessageType.GUI_MSG_CLICKED:
              int iControl=message.SenderControlId;
              if (iControl==(int)Controls.CONTROL_BTNVIEWASICONS)
              {
                // switch to next view
                switch (currentView)
                {
                  case View.VIEW_AS_LIST:
                    currentView=View.VIEW_AS_ICONS;
                    break;
                  case View.VIEW_AS_ICONS:
                    currentView=View.VIEW_AS_LARGEICONS;
                    break;
                  case View.VIEW_AS_LARGEICONS:
                    currentView=View.VIEW_AS_LIST;
                    break;
                }
                UpdateButtons();
                ShowThumbPanel();
                GUIControl.FocusControl(GetID,iControl);
              }
              else if (iControl==(int)Controls.CONTROL_THUMBS||iControl==(int)Controls.CONTROL_LIST)
              {
                // application or game-item was clicked....
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED,GetID,0,iControl,0,0,null);
                GUIGraphicsContext.SendMessage(msg);         
                int iItem=(int)msg.Param1;
                int iAction=(int)message.Param1;
      
                if (iAction == (int)Action.ActionType.ACTION_SELECT_ITEM)
                {
                  GUIListItem item = GetSelectedItem();
                  if( item.IsFolder )
                  {
                    if( item.Label.Equals( GameUtils.cBackLabel ) )
                    {
                      // "back" - item was clicked
                      if (lastApp != null)
                      {
                        // in gamescreen....
                        lastApp = null;
                        DisplayApplications();
                      }
                      else 
                      {
                        // in appscreen....
                        //  GUIWindowManager.PreviousWindow(); 
                      }
                    }
                    else
                    {
                      // application-item was clicked
                      string strApp = item.Label;
                      DisplayGames(strApp);
                    }
                  }
                  else
                  {
                    // game item was clicked => launch it!
                    string strGame = item.Label;
                    if (lastApp != null) 
                    {
                      lastApp.LaunchGame(strGame);
                    }
                  }
                }
              }
              if (iControl==(int)Controls.CONTROL_BTNSORTBY)
              {
                // get next sort method...
                OnSort();
                GUIControl.FocusControl(GetID,iControl);
              }
              break;
          }
          return base.OnMessage( message );
        }

    sorry for long post.... & thanks!

    & CHEERS! :D

    Daniel
     

    waeberd

    Portal Pro
    August 16, 2004
    314
    1
    Fribourg (CH)
    frodo said:
    make sure that the 8000 is unique. (Each window has its own ID
    and that the exact same ID is also mentioned in your xml file!
    (myplugin.xml in this case)

    FRODO, I LOVE YOU! :lol: <ermmm sorry>
    :!: Bingo :!:

    The ID was unique, but I simply included the myprograms.xml and in there was of course the wrong ID!
    Made my own copy of myprograms.xml, changed the reference and the ID... et voilà!!

    MILLION THANKS, man!
     

    Users who are viewing this thread

    Top Bottom