mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
755a9313e4
5 files changed
+94
-15
No files matched your search
@@ -32,6 +32,11 @@ public class AbilityHazard extends AbilityZone implements IAbilityHazard {
|
||||
this.activeAnimationName = "Ability_Zone_Active";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcurrentCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoneRadius() {
|
||||
return radius;
|
||||
|
||||
@@ -38,6 +38,11 @@ public class AbilityTrap extends AbilityZone implements IAbilityTrap {
|
||||
this.activeAnimationName = "Ability_Zone_Active";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcurrentCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoneRadius() {
|
||||
return triggerRadius;
|
||||
|
||||
@@ -1005,7 +1005,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
|
||||
if (chain != null && selectedEntryIndex < chain.getEntries().size()) {
|
||||
ChainedAbilityEntry entry = chain.getEntries().get(selectedEntryIndex);
|
||||
Ability resolved = entry.resolve();
|
||||
if (resolved != null) {
|
||||
if (resolved != null && !resolved.isBuiltIn()) {
|
||||
editingChainEntryParent = true;
|
||||
setSubGui(resolved.createConfigGui(this));
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
|
||||
}
|
||||
} else if (mode == SubGuiAbilityEditMode.MODE_MODIFY_PARENT) {
|
||||
Ability ability = slot.getAbility();
|
||||
if (ability != null) {
|
||||
if (ability != null && !ability.isBuiltIn()) {
|
||||
setSubGui(ability.createConfigGui(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import kamkeel.npcs.util.Register;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
@@ -21,6 +22,11 @@ import java.util.Map;
|
||||
*/
|
||||
public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomScrollListener, ITextfieldListener {
|
||||
|
||||
private static final int BTN_ADD = 0;
|
||||
private static final int BTN_CANCEL = 1;
|
||||
private static final int BTN_SCROLL_TYPE = 2;
|
||||
private static final int TF_SEARCH = 10;
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private final HashMap<String, String> displayNameToTypeId = new HashMap<>();
|
||||
private final HashMap<String, String> allDisplayNameToTypeId = new HashMap<>();
|
||||
@@ -37,28 +43,41 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
addTextField(new GuiNpcTextField(10, this, fontRendererObj, guiLeft + 5, guiTop + 5, 190, 18, search));
|
||||
int y = guiTop + 5;
|
||||
|
||||
// Scroll type filter button
|
||||
addButton(new GuiNpcButton(BTN_SCROLL_TYPE, guiLeft + 5, y, 190, 20, GuiNPCAbilities.scrollType.toString()));
|
||||
y += 24;
|
||||
|
||||
// Search bar
|
||||
addTextField(new GuiNpcTextField(TF_SEARCH, this, fontRendererObj, guiLeft + 5, y, 190, 18, search));
|
||||
y += 20;
|
||||
|
||||
// Scroll list (shortened to fit filter button within original ySize)
|
||||
if (scroll == null) {
|
||||
scroll = new GuiCustomScroll(this, 0);
|
||||
scroll.setSize(190, 145);
|
||||
scroll.setSize(190, 121);
|
||||
}
|
||||
scroll.guiLeft = guiLeft + 5;
|
||||
scroll.guiTop = guiTop + 26;
|
||||
scroll.guiTop = y;
|
||||
addScroll(scroll);
|
||||
|
||||
buildAllTypes();
|
||||
scroll.setUnsortedList(getFilteredTypeList());
|
||||
|
||||
addButton(new GuiNpcButton(0, guiLeft + 5, guiTop + 188, 90, 20, "gui.add"));
|
||||
getButton(0).setEnabled(scroll.hasSelected());
|
||||
addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 188, 90, 20, "gui.cancel"));
|
||||
addButton(new GuiNpcButton(BTN_ADD, guiLeft + 5, guiTop + 188, 90, 20, "gui.add"));
|
||||
getButton(BTN_ADD).setEnabled(scroll.hasSelected());
|
||||
addButton(new GuiNpcButton(BTN_CANCEL, guiLeft + 105, guiTop + 188, 90, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
private void buildAllTypes() {
|
||||
allDisplayNameToTypeId.clear();
|
||||
String[] types = AbilityController.Instance.getTypes();
|
||||
for (String typeId : types) {
|
||||
// Apply scroll type filter
|
||||
if (!matchesScrollType(typeId))
|
||||
continue;
|
||||
|
||||
String displayName = I18n.format(typeId);
|
||||
if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
|
||||
displayName = "\u00A7e" + displayName;
|
||||
@@ -67,6 +86,25 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
|
||||
}
|
||||
}
|
||||
|
||||
private boolean matchesScrollType(String typeId) {
|
||||
GuiNPCAbilities.ScrollType type = GuiNPCAbilities.scrollType;
|
||||
if (type == GuiNPCAbilities.ScrollType.ALL) {
|
||||
return true;
|
||||
} else if (type == GuiNPCAbilities.ScrollType.CNPC) {
|
||||
return typeId.startsWith("ability.cnpc.");
|
||||
} else if (type == GuiNPCAbilities.ScrollType.MODDED) {
|
||||
if (!Register.isEmpty("ability")) {
|
||||
List<String> registerList = Register.REGISTERED_NAMESPACES.get("ability");
|
||||
if (!registerList.isEmpty()) {
|
||||
String namespace = registerList.get(GuiNPCAbilities.modIndex);
|
||||
return typeId.startsWith("ability." + namespace + ".");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<String> getFilteredTypeList() {
|
||||
List<String> list = new ArrayList<>();
|
||||
displayNameToTypeId.clear();
|
||||
@@ -85,20 +123,51 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
|
||||
|
||||
@Override
|
||||
public void buttonEvent(GuiButton guibutton) {
|
||||
if (guibutton.id == 0 && scroll.hasSelected()) {
|
||||
int id = guibutton.id;
|
||||
|
||||
if (id == BTN_ADD && scroll.hasSelected()) {
|
||||
String displayName = scroll.getSelected();
|
||||
selectedTypeId = displayNameToTypeId.get(displayName);
|
||||
close();
|
||||
} else if (guibutton.id == 1) {
|
||||
} else if (id == BTN_CANCEL) {
|
||||
selectedTypeId = null;
|
||||
close();
|
||||
} else if (id == BTN_SCROLL_TYPE) {
|
||||
cycleScrollType();
|
||||
if (scroll != null) {
|
||||
scroll.resetScroll();
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
private void cycleScrollType() {
|
||||
if (GuiNPCAbilities.scrollType != GuiNPCAbilities.ScrollType.MODDED) {
|
||||
GuiNPCAbilities.ScrollType[] values = GuiNPCAbilities.ScrollType.values();
|
||||
GuiNPCAbilities.ScrollType next = values[(GuiNPCAbilities.scrollType.ordinal() + 1) % values.length];
|
||||
if (next == GuiNPCAbilities.ScrollType.MODDED && Register.isEmpty("ability")) {
|
||||
next = GuiNPCAbilities.ScrollType.ALL;
|
||||
}
|
||||
GuiNPCAbilities.scrollType = next;
|
||||
} else {
|
||||
List<String> list = Register.REGISTERED_NAMESPACES.get("ability");
|
||||
if (list != null && !list.isEmpty()) {
|
||||
if (GuiNPCAbilities.modIndex == list.size() - 1) {
|
||||
GuiNPCAbilities.scrollType = GuiNPCAbilities.ScrollType.ALL;
|
||||
} else {
|
||||
GuiNPCAbilities.modIndex = (GuiNPCAbilities.modIndex + 1) % list.size();
|
||||
}
|
||||
} else {
|
||||
GuiNPCAbilities.modIndex = 0;
|
||||
GuiNPCAbilities.scrollType = GuiNPCAbilities.ScrollType.ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if (guiCustomScroll.id == 0) {
|
||||
getButton(0).setEnabled(scroll.hasSelected());
|
||||
getButton(BTN_ADD).setEnabled(scroll.hasSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +182,9 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
|
||||
@Override
|
||||
public void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
if (getTextField(10) != null && getTextField(10).isFocused()) {
|
||||
if (!search.equals(getTextField(10).getText())) {
|
||||
search = getTextField(10).getText().toLowerCase();
|
||||
if (getTextField(TF_SEARCH) != null && getTextField(TF_SEARCH).isFocused()) {
|
||||
if (!search.equals(getTextField(TF_SEARCH).getText())) {
|
||||
search = getTextField(TF_SEARCH).getText().toLowerCase();
|
||||
scroll.setList(getFilteredTypeList());
|
||||
scroll.resetScroll();
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
|
||||
editingEntryIndex = -1;
|
||||
} else if (mode == SubGuiAbilityEditMode.MODE_MODIFY_PARENT) {
|
||||
Ability resolved = entry.resolve();
|
||||
if (resolved != null) {
|
||||
if (resolved != null && !resolved.isBuiltIn()) {
|
||||
editingParentAbility = true;
|
||||
setSubGui(resolved.createConfigGui(this));
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user