-
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.
Add per-dialogue custom screen layout
- Loading branch information
Showing
11 changed files
with
261 additions
and
10 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
37 changes: 37 additions & 0 deletions
37
src/main/java/org/ladysnake/blabber/api/client/BlabberScreenRegistry.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,37 @@ | ||
/* | ||
* Blabber | ||
* Copyright (C) 2022-2023 Ladysnake | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; If not, see <https://www.gnu.org/licenses>. | ||
*/ | ||
package org.ladysnake.blabber.api.client; | ||
|
||
import net.minecraft.client.gui.screen.ingame.HandledScreens; | ||
import net.minecraft.util.Identifier; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.ladysnake.blabber.impl.client.BlabberClient; | ||
import org.ladysnake.blabber.impl.common.DialogueScreenHandler; | ||
|
||
@ApiStatus.Experimental | ||
public final class BlabberScreenRegistry { | ||
/** | ||
* Registers a custom screen provider for a {@link org.ladysnake.blabber.impl.common.model.DialogueLayout}. | ||
*/ | ||
public static void register( | ||
Identifier layoutId, | ||
HandledScreens.Provider<DialogueScreenHandler, BlabberDialogueScreen> screenProvider | ||
) { | ||
BlabberClient.registerLayoutScreen(layoutId, screenProvider); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/ladysnake/blabber/impl/common/model/DialogueLayout.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,33 @@ | ||
/* | ||
* Blabber | ||
* Copyright (C) 2022-2023 Ladysnake | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; If not, see <https://www.gnu.org/licenses>. | ||
*/ | ||
package org.ladysnake.blabber.impl.common.model; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.util.Identifier; | ||
import org.ladysnake.blabber.Blabber; | ||
|
||
// TODO change to a polymorphic type + registry to allow passing arbitrary data to the screen | ||
public record DialogueLayout(Identifier type) { | ||
public static final Codec<DialogueLayout> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
Identifier.CODEC.fieldOf("type").forGetter(DialogueLayout::type) | ||
).apply(instance, DialogueLayout::new)); | ||
public static final Identifier CLASSIC_LAYOUT_ID = Blabber.id("classic"); | ||
public static final Identifier RPG_LAYOUT_ID = Blabber.id("rpg"); | ||
public static final DialogueLayout DEFAULT = new DialogueLayout(CLASSIC_LAYOUT_ID); | ||
} |
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.