-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Daylight Cycle Option (#22)
* Update gradle + deps * Remove wildcard imports * Implement daylight cycle logic * Handle old nightTime config * Remove unneeded code * Make state list final * Change to Arrays.asList * Move to write block * Revert and unset needsSavings only if its saving
- Loading branch information
Showing
6 changed files
with
115 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/me/eigenraven/personalspace/gui/WCycleButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package me.eigenraven.personalspace.gui; | ||
|
||
import java.awt.Rectangle; | ||
import java.util.List; | ||
|
||
import me.eigenraven.personalspace.world.DimensionConfig; | ||
|
||
public class WCycleButton extends WButton { | ||
|
||
final List<ButtonState> stateList; | ||
int currentIndex = 0; | ||
int length = 0; | ||
|
||
public WCycleButton(Rectangle position, String text, boolean dropShadow, int color, List<ButtonState> states, | ||
int initialIndex, Runnable onClick) { | ||
super(position, text, dropShadow, color, Icons.CHECKMARK, onClick); | ||
stateList = states; | ||
length = stateList.size(); | ||
currentIndex = initialIndex; | ||
this.buttonIcon = stateList.get(currentIndex).icon; | ||
} | ||
|
||
public DimensionConfig.DaylightCycle getState() { | ||
return stateList.get(currentIndex).cycle; | ||
} | ||
|
||
void next() { | ||
if (++currentIndex >= length) { | ||
currentIndex = 0; | ||
} | ||
this.buttonIcon = stateList.get(currentIndex).icon; | ||
} | ||
|
||
@Override | ||
protected boolean mouseClickedImpl(int x, int y, int button) { | ||
next(); | ||
return super.mouseClickedImpl(x, y, button); | ||
} | ||
|
||
public static class ButtonState { | ||
|
||
public final DimensionConfig.DaylightCycle cycle; | ||
public final Icons icon; | ||
|
||
ButtonState(DimensionConfig.DaylightCycle cycle, Icons icon) { | ||
this.cycle = cycle; | ||
this.icon = icon; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+114 Bytes
(100%)
src/main/resources/assets/personalspace/textures/widgets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.