Esempio n. 1
0
  private void titelPosition()
      throws ArithmeticException { // errechnet für Bildschirmgröße x,y die Position der Fonts
    xtitle1 = (width / 2 - menüSchriftStart.getWidth("START") / 2);
    xtitle2 = (width / 2 - menüSchriftStart.getWidth("OPTIONEN") / 2);
    xtitle3 = (width / 2 - menüSchriftStart.getWidth("CREDITS") / 2);

    ytitle1 = ((height / 4) - ((menüSchriftStart.getHeight("START")) / 2));
    ytitle2 = ((height / 2) - ((menüSchriftStart.getHeight("OPTIONEN")) / 2));
    ytitle3 = ((3 * height / 4) - ((menüSchriftStart.getHeight("CREDITS")) / 2));
  }
Esempio n. 2
0
  public ExtendedTextField() {
    setFullScreenMode(true);

    setCommandListener(this);

    exit = new Command("Exit", Command.EXIT, 1);
    open = new Command("Open", Command.ITEM, 1);
    newFile = new Command("New", Command.ITEM, 2);
    save = new Command("Save", Command.ITEM, 3);
    saveAs = new Command("Save As", Command.ITEM, 4);
    eval = new Command("Eval", Command.ITEM, 5);
    output = new Command("Output", Command.ITEM, 6);
    cls = new Command("Clear", Command.ITEM, 7);

    addCommand(exit);
    addCommand(newFile);
    addCommand(open);
    addCommand(save);
    addCommand(saveAs);
    addCommand(eval);
    addCommand(output);
    addCommand(cls);

    new Thread(this).start();

    // TODO: change font size?
    inputFont = Font.getDefaultFont();
    inputWidth = getWidth();
    inputHeight = inputFont.getHeight();
    linesOnScreen = getHeight() / inputHeight;

    addNewLine(0);
  }
Esempio n. 3
0
  public void init(GameContainer gc, StateBasedGame sbg)
      throws SlickException { // throws=nicht um Exception kümmern

    Image unscaledBackground = new Image("res/Pics/background.jpg");
    background = unscaledBackground.getScaledCopy(0.6f);

    schriftSchwarz =
        new AngelCodeFont(
            "res/Fonts/TakeCoverSchwarz.fnt", new Image("res/Fonts/TakeCoverSchwarz.png"));
    schriftRot = new AngelCodeFont("res/Fonts/TakeCover.fnt", new Image("res/Fonts/TakeCover.png"));
    menüSchriftStart = schriftSchwarz;
    menüSchriftOptionen = schriftSchwarz;
    menüSchriftCredits = schriftSchwarz;

    this.titelPosition();

    // Achtung Image = null!!!
    startKnopf =
        new MouseOverArea(
            gc,
            null,
            xtitle1,
            ytitle1,
            menüSchriftStart.getWidth("START"),
            menüSchriftStart.getHeight("START"));
    optionenKnopf =
        new MouseOverArea(
            gc,
            null,
            xtitle2,
            ytitle2,
            menüSchriftStart.getWidth("OPTIONEN"),
            menüSchriftStart.getHeight("OPTIONEN"));
    creditsKnopf =
        new MouseOverArea(
            gc,
            null,
            xtitle3,
            ytitle3,
            menüSchriftStart.getWidth("CREDITS"),
            menüSchriftStart.getHeight("CREDITS"));

    knopfGedrueckt = new Sound("res/Sounds/button-29.ogg");
  }
Esempio n. 4
0
 public Pause(Font font, int widht, int height) {
   this.height = height;
   this.widht = widht;
   this.font = font;
   colorB = Color.black;
   colorB.a = 0.6f;
   x = widht / 2 - font.getWidth(pause) / 2;
   y = height / 2 - font.getHeight(pause) / 2;
   colorF = Color.white;
 }
 public int getVHeight() {
   if (height != 0) return height;
   for (int i = 0; i < elementCount; i++) {
     int h = 0;
     Object o = elementData[i];
     if (o == null) continue;
     if (o instanceof String) {
       h = font.getHeight();
     } else if (o instanceof Integer) {
       int a = ((Integer) o).intValue();
       if ((a & 0xff000000) == 0) {
         h = imageList.getWidth();
       }
     } else if (o instanceof VirtualElement) {
       h = ((VirtualElement) o).getVHeight();
     }
     if (h > height) height = h;
   }
   return height;
 }
  public void drawItem(Graphics g, int offset, boolean selected, boolean drawsec) {
    // g.setColor(0);
    boolean ralign = false;
    boolean underline = false;

    // #if NICK_COLORS
    // # 	boolean nick=false;
    // #endif

    int w = offset;
    int dw;
    int imageYOfs = ((getVHeight() - imgHeight()) >> 1);
    // #if ALCATEL_FONT
    // #         int fontYOfs=(( getVHeight()-font.getHeight() )>>1) +1;
    // #else
    int fontYOfs = ((getVHeight() - font.getHeight()) >> 1);
    // #endif
    int imgWidth = imgWidth();

    g.setFont(font);
    for (int index = 0; index < elementCount; index++) {
      Object ob = elementData[index];
      if (ob != null) {

        if (ob instanceof String) {
          // string element
          String s = (String) ob;
          // #if NICK_COLORS
          // #                     if (nick) {
          // #                         int color=g.getColor();
          // #                         dw=0;
          // #                         int p1=0;
          // #                         while (p1<s.length()) {
          // #                             int p2=p1;
          // #                             char c1=s.charAt(p1);
          // #                             //processing the same cp
          // #                             while (p2<s.length()) {
          // #                                 char c2=s.charAt(p2);
          // #                                 if ( (c1&0xff00) != (c2 &0xff00) ) break;
          // #                                 p2++;
          // #                             }
          // #                             g.setColor( (c1>255) ? ColorScheme.strong(color) :
          // color);
          // #                             dw=font.substringWidth(s, p1, p2-p1);
          // #                             if (ralign) w-=dw;
          // #                             g.drawSubstring( s, p1, p2-p1,
          // #                                     w,fontYOfs,Graphics.LEFT|Graphics.TOP);
          // #                             if (!ralign) w+=dw;
          // #                             p1=p2;
          // #                         }
          // #
          // #                         g.setColor(color);
          // #                     } else {
          // #endif
          dw = font.stringWidth(s);
          if (ralign) w -= dw;
          g.drawString(s, w, fontYOfs, Graphics.LEFT | Graphics.TOP);
          if (underline) {
            int y = getVHeight() - 1;
            g.drawLine(w, y, w + dw, y);
            underline = false;
          }
          if (!ralign) w += dw;
          // #if NICK_COLORS
          // #                     }
          // #endif

        } else if ((ob instanceof Integer)) {
          // image element or color
          int i = ((Integer) ob).intValue();
          switch (i & 0xff000000) {
            case IMAGE:
              if (imageList == null) break;
              if (ralign) w -= imgWidth;
              imageList.drawImage(g, ((Integer) ob).intValue(), w, imageYOfs);
              if (!ralign) w += imgWidth;
              break;
            case COLOR:
              g.setColor(0xFFFFFF & i);
              break;
            case RALIGN:
              ralign = true;
              w = g.getClipWidth() - 1;
              break;
            case UNDERLINE:
              underline = true;
              break;
              // #if NICK_COLORS
              // #                         case NICK_ON:
              // #                             nick=true;
              // #                             break;
              // #                         case NICK_OFF:
              // #                             nick=false;
              // #                             break;
              // #endif
          }
        } /* Integer*/ else if (ob instanceof VirtualElement) {
          int clipw = g.getClipWidth();
          int cliph = g.getClipHeight();
          ((VirtualElement) ob).drawItem(g, 0, false, false);
          g.setClip(g.getTranslateX(), g.getTranslateY(), clipw, cliph);
          // TODO: рисование не с нулевой позиции и вычисление ширины
        }
      } // if ob!=null
    } // for
  }