Skip to content

Commit

Permalink
Fix a license and clean up some other code
Browse files Browse the repository at this point in the history
  • Loading branch information
OroArmor committed Jul 21, 2024
1 parent 110d052 commit 7df0d67
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 68 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ModNioPack(@Nullable String name, ModMetadata modInfo, @Nullable Text dis
super(new PackLocationInfo(
name,
displayName,
PackSource.PACK_SOURCE_BUILTIN,
new QuiltBuiltinPackProfile.BuiltinPackSource(modInfo, activationType),
Optional.empty()
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

import org.quiltmc.loader.api.ModMetadata;
import org.quiltmc.qsl.resource.loader.api.QuiltPackProfile;
import org.quiltmc.qsl.resource.loader.api.PackActivationType;

Expand Down Expand Up @@ -82,20 +83,20 @@ public PackCompatibility getCompatibility() {
*/
public static class BuiltinPackSource implements PackSource {
private static final Text SOURCE_BUILTIN_TEXT = Text.translatable("pack.source.builtin");
private final ModNioPack pack;
private final Text text;
private final Text tooltip;
private final PackActivationType activationType;

BuiltinPackSource(ModNioPack pack) {
String modName = pack.modInfo.name();
BuiltinPackSource(ModMetadata modInfo, PackActivationType activationType) {
String modName = modInfo.name();

if (modName == null) {
modName = pack.modInfo.id();
modName = modInfo.id();
}

this.pack = pack;
this.text = SOURCE_BUILTIN_TEXT;
this.tooltip = Text.translatable("options.generic_value", SOURCE_BUILTIN_TEXT, modName);
this.activationType = activationType;
}

@Override
Expand All @@ -105,7 +106,7 @@ public Text decorate(Text description) {

@Override
public boolean shouldAddAutomatically() {
return this.pack.getActivationType().isEnabledByDefault();
return this.activationType.isEnabledByDefault();
}

public Text getTooltip() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
/*
* Copyright 2024 The Quilt Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.quiltmc.qsl.resource.loader.impl.client;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.pack.PackScreen;
import net.minecraft.client.gui.widget.list.pack.PackEntryListWidget;

import org.quiltmc.qsl.resource.loader.impl.BuiltinResourcePackSource;
import org.quiltmc.qsl.resource.loader.impl.QuiltBuiltinPackProfile;
import org.quiltmc.qsl.resource.loader.mixin.client.PackScreenAccessor;
import org.quiltmc.qsl.resource.loader.mixin.client.ResourcePackEntryAccessor;
import org.quiltmc.qsl.screen.api.client.QuiltScreen;
Expand All @@ -17,14 +33,14 @@ public void afterRender(Screen screen, GuiGraphics graphics, int mouseX, int mou
if (screen instanceof PackScreen packScreen) {
PackEntryListWidget.PackEntry availableEntry = ((PackScreenAccessor) packScreen).getAvailablePackList().getHoveredEntry();
if (availableEntry != null) {
if (((ResourcePackEntryAccessor) availableEntry).getPack().getSource() instanceof BuiltinResourcePackSource source) {
if (((ResourcePackEntryAccessor) availableEntry).getPack().getSource() instanceof QuiltBuiltinPackProfile.BuiltinPackSource source) {
graphics.drawTooltip(((QuiltScreen) packScreen).getTextRenderer(), source.getTooltip(), mouseX, mouseY);
}
}

PackEntryListWidget.PackEntry selectedEntry = ((PackScreenAccessor) packScreen).getSelectedPackList().getHoveredEntry();
if (selectedEntry != null) {
if (((ResourcePackEntryAccessor) selectedEntry).getPack().getSource() instanceof BuiltinResourcePackSource source) {
if (((ResourcePackEntryAccessor) selectedEntry).getPack().getSource() instanceof QuiltBuiltinPackProfile.BuiltinPackSource source) {
graphics.drawTooltip(((QuiltScreen) packScreen).getTextRenderer(), source.getTooltip(), mouseX, mouseY);
}
}
Expand Down

0 comments on commit 7df0d67

Please sign in to comment.