Facebook
From Obese Frog, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 99
  1. // Decompiled with: CFR 0.152
  2. // Class Version: 6
  3. package age.of.civilizations2.jakowski.lukasz;
  4.  
  5. import age.of.civilizations2.jakowski.lukasz.CFG;
  6. import age.of.civilizations2.jakowski.lukasz.ImageManager;
  7. import age.of.civilizations2.jakowski.lukasz.Images;
  8. import age.of.civilizations2.jakowski.lukasz.MenuElement;
  9. import com.badlogic.gdx.graphics.Color;
  10. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  11.  
  12. class Button
  13. extends MenuElement {
  14.     protected TypeOfButton typeOfButton;
  15.     private Checkbox oCheckbox;
  16.     protected String sText = null;
  17.     protected int iTextWidth = -1;
  18.     protected int iTextHeight;
  19.     protected int iTextPositionX;
  20.     protected TextPosition textPosition;
  21.     protected boolean checkbox = false;
  22.     private boolean checkboxState = false;
  23.  
  24.     Button() {
  25.     }
  26.  
  27.     protected final void init(String string, int n, int n2, int n3, int n4, int n5, boolean bl, boolean bl2, boolean bl3, boolean bl4) {
  28.         this.init(string, n, n2, n3, n4, n5, bl, bl2, bl3, bl4, null);
  29.     }
  30.  
  31.     protected final void init(String string, int n, int n2, int n3, int n4, int n5, boolean bl, boolean bl2, boolean bl3, boolean bl4, TypeOfButton typeOfButton) {
  32.         this.typeOfElement = MenuElement.TypeOfElement.BUTTON;
  33.         this.setPosX(n2);
  34.         this.setPosY(n3);
  35.         this.setWidth(n4);
  36.         this.setHeight(n5);
  37.         this.setText(string);
  38.         this.iTextPositionX = n;
  39.         this.textPosition = n < 0 ? new TextPosition(){
  40.  
  41.             @Override
  42.             public int getTextPosition() {
  43.                 return Button.this.getWidth() / 2 - Button.this.getTextWidth() / 2;
  44.             }
  45.         } : new TextPosition(){
  46.  
  47.             @Override
  48.             public int getTextPosition() {
  49.                 return Button.this.iTextPositionX;
  50.             }
  51.         };
  52.         this.checkbox = bl3;
  53.         this.checkboxState = bl4;
  54.         this.oCheckbox = this.buildCheckbox();
  55.         this.setClickable(bl);
  56.         this.setVisible(bl2);
  57.         this.typeOfButton = typeOfButton;
  58.     }
  59.  
  60.     @Override
  61.     protected final void draw(SpriteBatch spriteBatch, int n, int n2, boolean bl, boolean bl2) {
  62.         if (this.getClickable()) {
  63.             this.drawButtonBG(spriteBatch, n, n2, bl);
  64.         } else {
  65.             spriteBatch.setColor(1.0f, 1.0f, 1.0f, 0.45f);
  66.             this.drawButtonBG(spriteBatch, n, n2, bl);
  67.             spriteBatch.setColor(Color.WHITE);
  68.         }
  69.         this.oCheckbox.drawCheckBox(spriteBatch, n, n2, bl2);
  70.         this.drawText(spriteBatch, n, n2, bl);
  71.     }
  72.  
  73.     protected Checkbox buildCheckbox() {
  74.         if (this.checkbox) {
  75.             return new Checkbox(){
  76.  
  77.                 @Override
  78.                 public void drawCheckBox(SpriteBatch spriteBatch, int n, int n2, boolean bl) {
  79.                     if (Button.this.getCheckboxState()) {
  80.                         spriteBatch.setColor(new Color(0.55f, 0.8f, 0.0f, 0.25f));
  81.                     } else {
  82.                         spriteBatch.setColor(new Color(0.8f, 0.137f, 0.0f, 0.25f));
  83.                     }
  84.                     ImageManager.getImage(Images.slider_gradient).draw(spriteBatch, Button.this.getPosX() + n, Button.this.getPosY() - ImageManager.getImage(Images.slider_gradient).getHeight() + 1 + n2, Button.this.getWidth() / 4, Button.this.getHeight() - 2, false, false);
  85.                     spriteBatch.setColor(new Color(0.0f, 0.0f, 0.0f, 0.3f));
  86.                     ImageManager.getImage(Images.gradient).draw(spriteBatch, Button.this.getPosX() + n, Button.this.getPosY() - ImageManager.getImage(Images.gradient).getHeight() + 1 + n2, Button.this.getWidth(), Button.this.getHeight() / 4, false, false);
  87.                     ImageManager.getImage(Images.gradient).draw(spriteBatch, Button.this.getPosX() + n, Button.this.getPosY() - ImageManager.getImage(Images.gradient).getHeight() + Button.this.getHeight() - 1 + n2 - Button.this.getHeight() / 4, Button.this.getWidth(), Button.this.getHeight() / 4, false, true);
  88.                     spriteBatch.setColor(Color.WHITE);
  89.                 }
  90.             };
  91.         }
  92.         return new Checkbox(){
  93.  
  94.             @Override
  95.             public void drawCheckBox(SpriteBatch spriteBatch, int n, int n2, boolean bl) {
  96.             }
  97.         };
  98.     }
  99.  
  100.     protected void drawButtonBG(SpriteBatch spriteBatch, int n, int n2, boolean bl) {
  101.     }
  102.  
  103.     protected void drawText(SpriteBatch spriteBatch, int n, int n2, boolean bl) {
  104.         if (bl) {
  105.             CFG.drawText(spriteBatch, this.getTextToDraw(), this.getPosX() + this.textPosition.getTextPosition() + n, this.getPosY() + this.getHeight() / 2 - this.iTextHeight / 2 + n2, this.getColor(bl));
  106.         } else {
  107.             CFG.drawTextWithShadow(spriteBatch, this.getTextToDraw(), this.getPosX() + this.textPosition.getTextPosition() + n, this.getPosY() + this.getHeight() / 2 - this.iTextHeight / 2 + n2, this.getColor(bl));
  108.         }
  109.     }
  110.  
  111.     protected Color getColor(boolean bl) {
  112.         return bl ? CFG.COLOR_BUTTON_GAME_TEXT_ACTIVE : (this.getClickable() ? new Color(0.38f, 0.38f, 0.38f, 1.0f) : new Color(0.49f, 0.49f, 0.49f, 0.5f));
  113.     }
  114.  
  115.     @Override
  116.     protected String getText() {
  117.         return this.sText;
  118.     }
  119.  
  120.     @Override
  121.     protected String getTextToDraw() {
  122.         return this.sText;
  123.     }
  124.  
  125.     @Override
  126.     public void setText(String string) {
  127.         block8: {
  128.             this.sText = string;
  129.             try {
  130.                 if (string != null) {
  131.                     CFG.glyphLayout.setText(CFG.fontMain, this.getText());
  132.                     this.iTextWidth = (int)CFG.glyphLayout.width;
  133.                     this.iTextHeight = (int)CFG.glyphLayout.height;
  134.                 } else {
  135.                     this.iTextHeight = 0;
  136.                     this.iTextWidth = 0;
  137.                 }
  138.             }
  139.             catch (IndexOutOfBoundsException indexOutOfBoundsException) {
  140.                 if (CFG.LOGS) {
  141.                     CFG.exceptionStack(indexOutOfBoundsException);
  142.                 }
  143.             }
  144.             catch (NullPointerException nullPointerException) {
  145.                 if (CFG.LOGS) {
  146.                     CFG.exceptionStack(nullPointerException);
  147.                 }
  148.             }
  149.             catch (IllegalArgumentException illegalArgumentException) {
  150.                 if (!CFG.LOGS) break block8;
  151.                 CFG.exceptionStack(illegalArgumentException);
  152.             }
  153.         }
  154.     }
  155.  
  156.     protected final void setCheckbox(boolean bl) {
  157.         this.checkbox = bl;
  158.     }
  159.  
  160.     @Override
  161.     protected boolean getCheckboxState() {
  162.         return this.checkboxState;
  163.     }
  164.  
  165.     @Override
  166.     protected final void setCheckboxState(boolean bl) {
  167.         this.checkboxState = bl;
  168.     }
  169.  
  170.     @Override
  171.     protected void setTypeOfButton(TypeOfButton typeOfButton) {
  172.         this.typeOfButton = typeOfButton;
  173.     }
  174.  
  175.     @Override
  176.     protected int getTextWidth() {
  177.         return this.iTextWidth;
  178.     }
  179.  
  180.     @Override
  181.     protected int getTextPos() {
  182.         return this.iTextPositionX;
  183.     }
  184.  
  185.     @Override
  186.     protected int getTextHeight() {
  187.         return this.iTextHeight;
  188.     }
  189.  
  190.     static interface TextPosition {
  191.         public int getTextPosition();
  192.     }
  193.  
  194.     static interface Checkbox {
  195.         public void drawCheckBox(SpriteBatch var1, int var2, int var3, boolean var4);
  196.     }
  197.  
  198.     protected static enum TypeOfButton {
  199.         KEYBOARD,
  200.         KEYBOARD_NUM,
  201.         KEYBOARD_ACTIVE,
  202.         KEYBOARD_SAVE,
  203.         KEYBOARD_OPTIONS;
  204.  
  205.     }
  206. }
  207.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Tiny Macaque text 1 Year ago.