Advertisement
Jnk1296

Menu

May 24th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.32 KB | None | 0 0
  1. package net.risenphoenix.jnk.StarField.Menus;
  2.  
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.RenderingHints;
  7.  
  8. import net.risenphoenix.jnk.StarField.Menus.Tutorials.HelpOne;
  9. import net.risenphoenix.jnk.StarField.Menus.Tutorials.HelpTwo;
  10.  
  11. public class Menu {
  12.    
  13.     public static SFMenu sfmenu = new MainMenu();
  14.    
  15.     public static int menu = 0;
  16.     public static final int NO_MENU = -1;
  17.     public static final int MAIN_MENU = 0;
  18.     public static final int OPTIONS_MENU = 1;
  19.     public static final int ABOUT_MENU = 2;
  20.     public static final int PAUSE_MENU = 3;
  21.     public static final int DEATH_MENU = 4;
  22.     public static final int HELP_MENU_1 = 5;
  23.     public static final int HELP_MENU_2 = 6;
  24.    
  25.     public void drawMenu(Graphics g) {
  26.         g.setFont(new Font("Century Gothic", Font.PLAIN, 40));
  27.        
  28.         // Antialias Text (GLOBAL)
  29.         Graphics2D g2D = (Graphics2D)g;
  30.         g2D.setRenderingHint(
  31.                 RenderingHints.KEY_TEXT_ANTIALIASING,
  32.                 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  33.        
  34.         // Main Menu
  35.         if (menu == MAIN_MENU) {
  36.             if (!sfmenu.getMenuName().equals("main") || sfmenu == null) {
  37.                 sfmenu = new MainMenu();
  38.             }
  39.            
  40.         // Options Menu
  41.         } else if (menu == OPTIONS_MENU) {
  42.             if (!sfmenu.getMenuName().equals("options") || sfmenu == null) {
  43.                 sfmenu = new OptionsMenu();
  44.             }
  45.        
  46.         // About Display
  47.         } else if (menu == ABOUT_MENU) {
  48.             if (!sfmenu.getMenuName().equals("about") || sfmenu == null) {
  49.                 sfmenu = new AboutMenu();
  50.             }
  51.        
  52.         // Pause Menu
  53.         } else if (menu == PAUSE_MENU) {
  54.             if (!sfmenu.getMenuName().equals("pause") || sfmenu == null) {
  55.                 sfmenu = new PauseMenu();
  56.             }
  57.                        
  58.         // Death (Gameover) Menu
  59.         } else if (menu == DEATH_MENU) {
  60.             if (!sfmenu.getMenuName().equals("death") || sfmenu == null) {
  61.                 sfmenu = new DeathMenu();
  62.             }
  63.            
  64.         // How to Play 1   
  65.         } else if (menu == HELP_MENU_1) {
  66.             if (!sfmenu.getMenuName().equals("help_1") || sfmenu == null) {
  67.                 sfmenu = new HelpOne();
  68.             }
  69.            
  70.         // How to Play 2
  71.         } else if (menu == HELP_MENU_2) {
  72.             if (!sfmenu.getMenuName().equals("help_2") || sfmenu == null) {
  73.                 sfmenu = new HelpTwo();
  74.             }
  75.            
  76.         // No Menu 
  77.         } else if (menu == NO_MENU) {
  78.             if (sfmenu != null) {
  79.                 sfmenu = null;
  80.             }
  81.         }
  82.        
  83.         // Render Menu
  84.         if (menu != NO_MENU) {
  85.             sfmenu.drawMenu(g);
  86.         }
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement