We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Common interface for several sketches
Page Index Toggle Pages: 1
Common interface for several sketches (Read 1191 times)
Common interface for several sketches
Jun 21st, 2006, 1:20pm
 
Has anyone have or tried to create a common interface (or main menu) from which to launch different sketches in application mode.  I need to do something like this for an exhibition.  Kind of like a DVD menu.

My requirements would be:
- At the end I want an Application
- Fullscreen and present mode (for the main menu and the sketches)
- If a sketch crashes, breaks or closes normally you go back to the main menu screen
- Block the user from closing the main menu (no ALT+TAB, CTRL+ALT+DEL,...)

Any ideas of how to start? any clues? I'm quite lost.

I would like to make this main menu in Processing, so it could be nice to have some kind of method for calling external applications, and putting the current one in hold.

Does this has something to do with getAppletContext()?

But If someone has other directions or solutions please let me know.

Thanks
Re: Common interface for several sketches
Reply #1 - Jun 21st, 2006, 1:34pm
 
Here is what I did

Quote:


import processing.opengl.*;

import processing.core.PApplet;

public class Main extends PApplet{

 public abstract class View extends PApplet{

   abstract public void openView();

   abstract public void closeView();
 }

 public class View1 extends View{

   public void openView(){
     println("opened view 1");
   }

   public void closeView(){
     println("closed view 1");
   }

   public void draw(){
     background(255,0,0);
   }

 }

 public class View2 extends View{

   public void openView(){
     println("opened view 2");
   }

   public void closeView(){
     println("closed view 2");
   }

   public void draw(){
     background(0,255,0);
   }

 }

 View view1;
 View view2;

 View currentView;

 private void initView(final View i_view){
   i_view.g = g;
   i_view.width = width;
   i_view.height = height;
   i_view.setup();
 }

 public void setup(){
   size(800, 600, OPENGL);

   view1 = new View1();
   initView(view1);

   view2 = new View2();
   initView(view2);

   currentView = view1;
 }

 public void draw(){
   try{
     currentView.draw();
   }
   catch(Exception e){
     e.printStackTrace();
   }
 }

 private void openView(final View i_view){
   currentView.closeView();
   currentView = i_view;
   currentView.openView();
 }

 public void keyPressed(){
   if(currentView == view1){
     openView(view2);
   }
   else{
     openView(view1);
   }
 }
}


Re: Common interface for several sketches
Reply #2 - Jun 21st, 2006, 2:09pm
 
Thanks man!!!

It looks like pretty good hack.  I'll give it a try this afternoon.

see ya
Page Index Toggle Pages: 1