-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
985 additions
and
570 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
38 changes: 0 additions & 38 deletions
38
common/src/main/java/sh/okx/civmodern/common/gui/ColorValue.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
common/src/main/java/sh/okx/civmodern/common/gui/screen/AbstractConfigScreen.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,80 @@ | ||
package sh.okx.civmodern.common.gui.screen; | ||
|
||
import java.util.Objects; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import org.jetbrains.annotations.NotNull; | ||
import sh.okx.civmodern.common.CivMapConfig; | ||
|
||
abstract class AbstractConfigScreen extends Screen { | ||
private static final int PADDING_Y = 15; | ||
private static final int DEFAULT_WIDGET_HEIGHT = 20; | ||
|
||
protected final Screen parent; | ||
protected final CivMapConfig config; | ||
|
||
AbstractConfigScreen( | ||
final @NotNull CivMapConfig config, | ||
final Screen parent, | ||
final @NotNull Component title | ||
) { | ||
super(Objects.requireNonNull(title)); | ||
this.config = Objects.requireNonNull(config); | ||
this.parent = parent; | ||
} | ||
|
||
protected int centreX; | ||
|
||
/** | ||
* Override this but call super first! | ||
*/ | ||
@Override | ||
protected void init() { | ||
this.centreX = this.width / 2; | ||
} | ||
|
||
/** | ||
* Returns where the header text should go. | ||
*/ | ||
protected int getHeaderY() { | ||
return PADDING_Y; | ||
} | ||
|
||
/** | ||
* Returns the starting-Y of the body (1/6th of the height down from the top), or 10 below the header, whichever is | ||
* lower on-screen. | ||
*/ | ||
protected int getBodyY() { | ||
return getBodyY(this.height / 6); | ||
} | ||
|
||
/** | ||
* Returns the starting-Y of the body, returning either the provided preferred Y, or 10 below the header, whichever | ||
* is lower on-screen. | ||
*/ | ||
protected int getBodyY( | ||
final int preferredOffsetY | ||
) { | ||
return Math.max( | ||
preferredOffsetY, | ||
getHeaderY() + this.font.lineHeight + 10 // 10-padding below the header | ||
); | ||
} | ||
|
||
/** | ||
* Returns the Y for any done-button or similar, choosing either 15 from the bottom, or the provided Y, whichever is | ||
* lower on-screen. | ||
*/ | ||
protected int getFooterY( | ||
final int offsetY | ||
) { | ||
return Math.max(offsetY, this.height - PADDING_Y - DEFAULT_WIDGET_HEIGHT); | ||
} | ||
|
||
@Override | ||
public void onClose() { | ||
// Do not call super: it's just this but with a null instead of this.parent | ||
//super.onClose(); | ||
this.minecraft.setScreen(this.parent); | ||
} | ||
} |
Oops, something went wrong.