-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged to rebase MuTEMaster and fix any non-compile errors and game not launching in there * some docs on a few methods * innitial GUI class * try to implement guis * almost working - fix comflict * add UIBuildContext to getGUI method * make it compile * sketch gui - fix conflict
- Loading branch information
Showing
22 changed files
with
856 additions
and
306 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package gregtech.api.gui; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; | ||
import com.gtnewhorizons.modularui.api.screen.ModularWindow; | ||
import com.gtnewhorizons.modularui.api.screen.UIBuildContext; | ||
|
||
public interface GUIHost extends ITileWithModularUI { | ||
|
||
@Nonnull | ||
@Override | ||
default ModularWindow createWindow(UIBuildContext uiContext) { | ||
Objects.requireNonNull(uiContext); | ||
GUIProvider<?> gui = getGUI(uiContext); | ||
return gui.openGUI(uiContext); | ||
} | ||
|
||
/** | ||
* Width of the GUI when its being displayed | ||
*/ | ||
default int getWidth() { | ||
return 170; | ||
} | ||
|
||
default int getHeight() { | ||
return 192; | ||
} | ||
|
||
@Nonnull | ||
GUIProvider<?> getGUI(@Nonnull UIBuildContext uiContext); | ||
|
||
ItemStack getAsItem(); | ||
|
||
String getMachineName(); | ||
|
||
default boolean hasItemInput() { | ||
return true; | ||
} | ||
|
||
default boolean hasItemOutput() { | ||
return true; | ||
} | ||
|
||
default boolean hasFluidInput() { | ||
return true; | ||
} | ||
|
||
default boolean hasFluidOutput() { | ||
return true; | ||
} | ||
} |
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,38 @@ | ||
package gregtech.api.gui; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import com.gtnewhorizons.modularui.api.screen.ModularWindow; | ||
import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; | ||
import com.gtnewhorizons.modularui.api.screen.UIBuildContext; | ||
|
||
public abstract class GUIProvider<T extends GUIHost> { | ||
|
||
@Nonnull | ||
protected final T host; | ||
|
||
public GUIProvider(@Nonnull T host) { | ||
this.host = host; | ||
} | ||
|
||
@Nonnull | ||
public ModularWindow openGUI(@Nonnull UIBuildContext uiContext) { | ||
Builder builder = Objects.requireNonNull(ModularWindow.builder(host.getWidth(), host.getHeight())); | ||
if (shouldBindPlayerInventory()) { | ||
builder.bindPlayerInventory(uiContext.getPlayer()); | ||
} | ||
attachSynchHandlers(builder, uiContext); | ||
addWidgets(builder, uiContext); | ||
return Objects.requireNonNull(builder.build()); | ||
} | ||
|
||
protected abstract void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); | ||
|
||
protected abstract void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); | ||
|
||
protected boolean shouldBindPlayerInventory() { | ||
return true; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.