]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/gui/BoolButton.java
Allow colors to be configured
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / BoolButton.java
1 package com.irtimaled.bbor.client.gui;
2
3 import com.irtimaled.bbor.client.config.ColorHelper;
4 import com.irtimaled.bbor.client.config.ConfigManager;
5
6 public abstract class BoolButton extends AbstractButton {
7     private boolean value;
8
9     BoolButton(int width, String label, boolean enabled) {
10         super(0, 0, width, label, enabled);
11     }
12
13     BoolButton(int width, String label) {
14         super(0, 0, width, label);
15     }
16
17     @Override
18     protected int getState() {
19         return enabled ? super.getState() : 0;
20     }
21
22     protected boolean getValue() {
23         return this.value;
24     }
25
26     protected void setValue(boolean value) {
27         this.value = value;
28     }
29
30     @Override
31     protected void renderBackground(int mouseX, int mouseY) {
32         int left = this.x + 1;
33         int top = this.y + 1;
34         int right = left + this.width - 2;
35         int bottom = top + this.height - 2;
36         if (this.getValue()) {
37             drawRectangle(left, top, right, bottom, ColorHelper.getColor(ConfigManager.buttonOnOverlay));
38         }
39     }
40 }