diff --git a/README.md b/README.md index c440594..47b6276 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Thinker is currently in development, and the list of features to be implemented [ ]Detect the object pointed to by the mouse +[x]Folder-like thinking profiles management Thinker提供了一个强大的帮助gui,允许通过json创建任意的方块/方块实体/来自GeckoLib的方块模型 和 文字/图片等,可以让整合包作者制作直观而简洁易懂的帮助页面 @@ -25,5 +26,6 @@ Thinker目前仍处于开发中,仍待实现的功能列表: [ ]检测鼠标指向的物体 +[x]文件夹式的沉思情景管理 diff --git a/src/main/java/cn/kuzuanpa/thinker/client/ThinkingGuiMain.java b/src/main/java/cn/kuzuanpa/thinker/client/ThinkingGuiMain.java index 087e361..157863d 100644 --- a/src/main/java/cn/kuzuanpa/thinker/client/ThinkingGuiMain.java +++ b/src/main/java/cn/kuzuanpa/thinker/client/ThinkingGuiMain.java @@ -101,21 +101,6 @@ public void initGui() { buttonList.add(new ThinkingProfileList(3,0,0,displayHeight).addToList(buttonsHaveAnime)); buttonList.add(new thinkerImage(4,65,0,0,32,16,16,"textures/gui/think/base.png", l10n("thinker.list.fold")).addToList(buttonsHaveAnime)); buttonList.add(new thinkerImage(5,-16,0,16,32,16,16,"textures/gui/think/base.png",l10n("thinker.list.unfold")).addToList(buttonsHaveAnime)); - //ArrayList blocks=new ArrayList<>(); - ////blocks.put(new BlockPosition(4,2,4),new dummyWorldBlock(Blocks.chest,new DummyBlockAnimeOutlineGlowth(1000,20000,new BlockPosition(4,2,4),-1,4))); - ////blocks.put(new BlockPosition(5,2,5),new dummyWorldBlock(Blocks.chest,new DummyBlockAnimeRotateSteadily())); - //blocks.add(new dummyWorldBlock( new BlockPosition(0,2,0), Blocks.dark_oak_stairs,new DummyWorldGraphicAnimeRotateSteadily()).setRenderAllFace(true)); - //blocks.add(new dummyWorldBlock( new BlockPosition(0,3,0), Blocks.daylight_detector,new DummyWorldGraphicAnimeRotateSteadily())); - //blocks.add(new dummyWorldBlock( new BlockPosition(1,2,0), Blocks.double_wooden_slab)); - //blocks.add(new dummyWorldBlock( new BlockPosition(3,2,0), Blocks.fence)); - //blocks.add(new dummyWorldBlock( new BlockPosition(1,1,0), Blocks.acacia_stairs).setRenderAllFace(true)); - //blocks.add(new dummyWorldBlock( new BlockPosition(0,2,5), Blocks.diamond_block)); - //blocks.add(new dummyWorldBlock( new BlockPosition(0,2,4), Blocks.diamond_block)); - //blocks.add(new dummyWorldBlock( new BlockPosition(2,2,0), Blocks.stained_glass)); - //blocks.add(new dummyWorldBlock( new BlockPosition(2,2,1), MultiTileEntityRegistry.getRegistry("gt.multitileentity").getItem(10005), new DummyWorldGraphicAnimeMoveLinear(0,10000,1,1,1))); - //blocks.add(new dummyWorldBlock( new BlockPosition(2,3,1), MultiTileEntityRegistry.getRegistry("ktfru.multitileentity").getItem(31001), new DummyWorldGraphicAnimeMoveLinear(0,10000,1,1,1))); - //blocks.add(new dummyWorldBlock( new BlockPosition(2,4,1), MultiTileEntityRegistry.getRegistry("ktfru.multitileentity").getItem(31001), new DummyWorldGraphicAnimeMoveLinear(0,10000,1,1,1))); - //blocks.add(new dummyWorldGeckoModel( new BlockPosition(2,5,1), "botarium.geo.json","ideas/botarium.png","botarium.animation.json")); profileHandler.clearAllProfile(); try { @@ -163,13 +148,13 @@ protected boolean onButtonPressed(GuiButton button) { if(button.id==2) this.mc.displayGuiScreen(new ThinkerSettingsGui()); if(button.id==3) { int mouseY=this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; - if(Mouse.isInsideWindow())for (int i : profileHandler.displayProfileIDMap.keySet())if(mouseY>=YOffset+i*(16+ configHandler.themeSelectorProfileGap.get()) && mouseY<=YOffset+16+i*(16+ configHandler.themeSelectorProfileGap.get())){ - if(!Objects.equals(selectedProfileID, displayProfileIDMap.get(i))){ - onProfileChanged(displayProfileIDMap.get(i)); + if(Mouse.isInsideWindow()){ + String newID=((ThinkingProfileList) button).onMouseClick(mouseY); + if(!Objects.equals(selectedProfileID, newID)&&profileHandler.getProfile(newID)!=null){ + onProfileChanged(newID); if(configHandler.themeSelectorAutoFold.get())foldThemeSelector(false); ((DummyWorldButton)buttonList.get(1)).clickOnOtherButton=false; } - break; } } if(button.id==4&&!themeSelectorFolded) foldThemeSelector(false); @@ -182,6 +167,8 @@ public void foldThemeSelector(boolean immediately){ ((ThinkerButtonBase)buttonList.get(4)).addAnime(new animeMoveLinear((int) (System.currentTimeMillis()-initTime)-(immediately?10:0), (int) (System.currentTimeMillis()-initTime+ (immediately?0:configHandler.getConfiguredAnimeTime(500))),-80,0)); ((ThinkerButtonBase)buttonList.get(5)).addAnime(new animeMoveLinear((int) (System.currentTimeMillis()-initTime)-(immediately?10:0), (int) (System.currentTimeMillis()-initTime+ (immediately?0:configHandler.getConfiguredAnimeTime(200))),16,0)); themeSelectorFolded=true; + unfoldedDirs.clear(); + } public void unfoldThemeSelector(){ ((ThinkerButtonBase)buttonList.get(3)).addAnime(new animeMoveLinear((int) (System.currentTimeMillis()-initTime), (int) (System.currentTimeMillis()-initTime+ configHandler.getConfiguredAnimeTime(500)),80,0)); diff --git a/src/main/java/cn/kuzuanpa/thinker/client/handler/profileHandler.java b/src/main/java/cn/kuzuanpa/thinker/client/handler/profileHandler.java index a7fdb23..909a94f 100644 --- a/src/main/java/cn/kuzuanpa/thinker/client/handler/profileHandler.java +++ b/src/main/java/cn/kuzuanpa/thinker/client/handler/profileHandler.java @@ -41,8 +41,9 @@ public class profileHandler { public static thinkingProfile selectedProfile; public static float oldWheel=0F,YOffset=0; private static final HashMap profileMap =new HashMap<>(); - public static Map displayProfileIDMap = new HashMap<>(); public static int profileLayer=1; + public static LinkedHashMap rootDir=new LinkedHashMap<>(); + public static ArrayList unfoldedDirs =new ArrayList<>(); public static void handleMouseWheel(){ oldWheel+=Mouse.getEventDWheel(); } @@ -58,88 +59,166 @@ public static void tick(){ public static void onProfileChanged(String profileID){ selectedProfile= profileMap.get(profileID); } - public static void addProfile(thinkingProfile profile){ profileMap.put(profile.id,profile); refreshDisplayIDMap();} - public static void addProfiles(List profiles){profiles.forEach(profile->profileMap.put(profile.id,profile));refreshDisplayIDMap();} + public static void addProfile(thinkingProfile profile){ profileMap.put(profile.id,profile);} + public static void addProfiles(List profiles){profiles.forEach(profile->profileMap.put(profile.id,profile));} public static void clearAllProfile(){profileMap.clear();} public static void removeProfile(String id){profileMap.remove(id);} public static HashMap getProfileMap(){return profileMap;} - public static void refreshDisplayIDMap(){ - AtomicInteger i = new AtomicInteger(0); - profileMap.forEach((k, v)->displayProfileIDMap.put(i.getAndIncrement(),k)); - } - public static thinkingProfile getProfile(String id){return profileMap.get(id);} public static boolean isItemHaveProfile(String itemId){return profileMap.values().stream().anyMatch(v-> v.bindItemId.equals(itemId));} public static thinkingProfile getProfileFromItem(String itemId){return profileMap.values().stream().filter(v->v.bindItemId.equalsIgnoreCase(itemId)).findFirst().orElse(null);} - public static class thinkingProfile{ - public thinkingProfile(String id, ThinkerButtonBase... buttons){this(id,null,0,0,0,0,buttons);} - public thinkingProfile(String id, IIcon icon, ThinkerButtonBase... buttons){this(id,icon,1,1,1,1,buttons);} - public thinkingProfile(String id, IIcon icon,int iconRGBA, ThinkerButtonBase... buttons){this(id,icon,(float)(iconRGBA >> 16 & 255) / 255.0F,(iconRGBA >> 8 & 255) / 255.0F,(iconRGBA & 255) /255.0F,(float)(iconRGBA >> 24 & 255),buttons);} - public thinkingProfile(String id, IIcon icon,short[] iconRGBA, ThinkerButtonBase... buttons){this(id,icon,(float)iconRGBA[0] / 255.0F,(float)iconRGBA[1] / 255.0F,(float)iconRGBA[2] /255.0F,(float)iconRGBA[3] / 255.0F,buttons);} - public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, ThinkerButtonBase... buttons){ - this.id=id; - this.disableDummyWorldRend=true; - this.icon=icon; - this.iconR=iconR; - this.iconG=iconG; - this.iconB=iconB; - this.iconA=iconA; + public static void buildDirTree(){ + rootDir.clear(); + profileMap.forEach((id,profile)->{ + if (profile.dir==null)rootDir.put(id,profile); + else rootDir.putAll(sortMap(walkDirTree(profile.dir, profile.id,rootDir))); + }); + rootDir=sortMap(rootDir); + } + + public static LinkedHashMap sortMap(LinkedHashMap map){ + LinkedHashMap profiles = new LinkedHashMap<>(); + LinkedHashMap dirs = new LinkedHashMap<>(); + map.forEach((k,v)->{ + if(v instanceof thinkingProfile)profiles.put(k,v); + if(v instanceof LinkedHashMap) { + dirs.put(k,sortMap((LinkedHashMap) v)); + } + }); + LinkedHashMap mapReturn = new LinkedHashMap<>(); + + mapReturn.putAll(dirs); + mapReturn.putAll(profiles); + + return mapReturn; + } + public static LinkedHashMap walkDirTree(String[] input, String profileID,LinkedHashMap upperDir){ + + LinkedHashMap result = new LinkedHashMap<>(); + if(input.length>0&&upperDir.get(input[0]) instanceof LinkedHashMap){ + //currentDir already exist + ((LinkedHashMap)upperDir.get(input[0])).putAll(walkDirTree(Arrays.copyOfRange(input, 1, input.length), profileID,(LinkedHashMap)upperDir.get(input[0]))); + }else { + //no more dir, return profile + if(input.length==0||input[0].equals(""))result.put(profileID,profileMap.get(profileID)); + //current Dir not exist, create new one + else result.put(input[0],walkDirTree(Arrays.copyOfRange(input, 1, input.length), profileID,result)); + } + return result; + } + public static class thinkingProfile { + public thinkingProfile(String id, ThinkerButtonBase... buttons) { + this(id, null, 0, 0, 0, 0, buttons); + } + + public thinkingProfile(String id, IIcon icon, ThinkerButtonBase... buttons) { + this(id, icon, 1, 1, 1, 1, buttons); + } + + public thinkingProfile(String id, IIcon icon, int iconRGBA, ThinkerButtonBase... buttons) { + this(id, icon, (float) (iconRGBA >> 16 & 255) / 255.0F, (iconRGBA >> 8 & 255) / 255.0F, (iconRGBA & 255) / 255.0F, (float) (iconRGBA >> 24 & 255), buttons); + } + + public thinkingProfile(String id, IIcon icon, short[] iconRGBA, ThinkerButtonBase... buttons) { + this(id, icon, (float) iconRGBA[0] / 255.0F, (float) iconRGBA[1] / 255.0F, (float) iconRGBA[2] / 255.0F, (float) iconRGBA[3] / 255.0F, buttons); + } + + public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, ThinkerButtonBase... buttons) { + this.id = id; + this.disableDummyWorldRend = true; + this.icon = icon; + this.iconR = iconR; + this.iconG = iconG; + this.iconB = iconB; + this.iconA = iconA; Collections.addAll(this.buttons, buttons); } - public thinkingProfile(String id, List buttons){this(id,null,0,0,0,0,buttons);} - public thinkingProfile(String id, IIcon icon, List buttons){this(id,icon,1,1,1,1,buttons);} - public thinkingProfile(String id, IIcon icon,int iconRGBA, List buttons){this(id,icon,(float)(iconRGBA >> 16 & 255) / 255.0F,(iconRGBA >> 8 & 255) / 255.0F,(iconRGBA & 255) /255.0F,(float)(iconRGBA >> 24 & 255),buttons);} - public thinkingProfile(String id, IIcon icon,short[] iconRGBA, List buttons){this(id,icon,(float)iconRGBA[0] / 255.0F,(float)iconRGBA[1] / 255.0F,(float)iconRGBA[2] /255.0F,(float)iconRGBA[3] / 255.0F,buttons);} - public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, List buttons){ - this.id=id; - this.disableDummyWorldRend=true; - this.icon=icon; - this.iconR=iconR; - this.iconG=iconG; - this.iconB=iconB; - this.iconA=iconA; - this.buttons= (ArrayList) buttons; - } - - public thinkingProfile(String id, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons){this(id,null,0,0,0,0,dummyWorldThinkerObjects,buttons);} - public thinkingProfile(String id, IIcon icon, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons){this(id,icon,1,1,1,1,dummyWorldThinkerObjects,buttons);} - public thinkingProfile(String id, IIcon icon, int iconRGBA, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons){this(id,icon,(float)(iconRGBA >> 16 & 255) / 255.0F,(iconRGBA >> 8 & 255) / 255.0F,(iconRGBA & 255) /255.0F,(float)(iconRGBA >> 24 & 255),dummyWorldThinkerObjects,buttons);} - public thinkingProfile(String id, IIcon icon, short[] iconRGBA, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons){this(id,icon,(float)iconRGBA[0] / 255.0F,(float)iconRGBA[1] / 255.0F,(float)iconRGBA[2] /255.0F,(float)iconRGBA[3] / 255.0F,dummyWorldThinkerObjects,buttons);} - public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons){ - this.id=id; - this.disableDummyWorldRend=false; - this.icon=icon; - this.iconR=iconR; - this.iconG=iconG; - this.iconB=iconB; - this.iconA=iconA; - this.dummyWorldThinkerObjects=dummyWorldThinkerObjects; + public thinkingProfile(String id, List buttons) { + this(id, null, 0, 0, 0, 0, buttons); + } + + public thinkingProfile(String id, IIcon icon, List buttons) { + this(id, icon, 1, 1, 1, 1, buttons); + } + + public thinkingProfile(String id, IIcon icon, int iconRGBA, List buttons) { + this(id, icon, (float) (iconRGBA >> 16 & 255) / 255.0F, (iconRGBA >> 8 & 255) / 255.0F, (iconRGBA & 255) / 255.0F, (float) (iconRGBA >> 24 & 255), buttons); + } + + public thinkingProfile(String id, IIcon icon, short[] iconRGBA, List buttons) { + this(id, icon, (float) iconRGBA[0] / 255.0F, (float) iconRGBA[1] / 255.0F, (float) iconRGBA[2] / 255.0F, (float) iconRGBA[3] / 255.0F, buttons); + } + + public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, List buttons) { + this.id = id; + this.disableDummyWorldRend = true; + this.icon = icon; + this.iconR = iconR; + this.iconG = iconG; + this.iconB = iconB; + this.iconA = iconA; + this.buttons.addAll(buttons); + } + + public thinkingProfile(String id, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons) { + this(id, null, 0, 0, 0, 0, dummyWorldThinkerObjects, buttons); + } + + public thinkingProfile(String id, IIcon icon, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons) { + this(id, icon, 1, 1, 1, 1, dummyWorldThinkerObjects, buttons); + } + + public thinkingProfile(String id, IIcon icon, int iconRGBA, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons) { + this(id, icon, (float) (iconRGBA >> 16 & 255) / 255.0F, (iconRGBA >> 8 & 255) / 255.0F, (iconRGBA & 255) / 255.0F, (float) (iconRGBA >> 24 & 255), dummyWorldThinkerObjects, buttons); + } + + public thinkingProfile(String id, IIcon icon, short[] iconRGBA, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons) { + this(id, icon, (float) iconRGBA[0] / 255.0F, (float) iconRGBA[1] / 255.0F, (float) iconRGBA[2] / 255.0F, (float) iconRGBA[3] / 255.0F, dummyWorldThinkerObjects, buttons); + } + + public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, List dummyWorldThinkerObjects, ThinkerButtonBase... buttons) { + this.id = id; + this.disableDummyWorldRend = false; + this.icon = icon; + this.iconR = iconR; + this.iconG = iconG; + this.iconB = iconB; + this.iconA = iconA; + this.dummyWorldThinkerObjects.addAll(dummyWorldThinkerObjects); Collections.addAll(this.buttons, buttons); } - public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, ArrayList dummyWorldThinkerObjects, List buttons){ - this.id=id; - this.disableDummyWorldRend=false; - this.icon=icon; - this.iconR=iconR; - this.iconG=iconG; - this.iconB=iconB; - this.iconA=iconA; - this.dummyWorldThinkerObjects=dummyWorldThinkerObjects; - this.buttons= (ArrayList) buttons; - } - public boolean disableDummyWorldRend=false; - public IIcon icon; - public float iconR,iconG,iconB,iconA; - public List dummyWorldThinkerObjects = new ArrayList<>(); - public ArrayList buttons = new ArrayList<>(); - public String id; + public thinkingProfile(String id, IIcon icon, float iconR, float iconG, float iconB, float iconA, ArrayList dummyWorldThinkerObjects, List buttons) { + this.id = id; + this.disableDummyWorldRend = false; + this.icon = icon; + this.iconR = iconR; + this.iconG = iconG; + this.iconB = iconB; + this.iconA = iconA; + this.dummyWorldThinkerObjects.addAll(dummyWorldThinkerObjects); + this.buttons.addAll(buttons); + } + + public final boolean disableDummyWorldRend; + public final IIcon icon; + public final float iconR, iconG, iconB, iconA; + public final List dummyWorldThinkerObjects = new ArrayList<>(); + public final ArrayList buttons = new ArrayList<>(); + public final String id; + public String[] dir; public String bindItemId = ""; - public thinkingProfile setBindItemId(String unlocalizedName){ + + public thinkingProfile setBindItemId(String unlocalizedName) { bindItemId = unlocalizedName; return this; } + + public thinkingProfile setDir(String[] dir) { + this.dir = dir; + return this; + } } } diff --git a/src/main/java/cn/kuzuanpa/thinker/client/json/thinkerJsonReader.java b/src/main/java/cn/kuzuanpa/thinker/client/json/thinkerJsonReader.java index 7cf286c..baf4e9b 100644 --- a/src/main/java/cn/kuzuanpa/thinker/client/json/thinkerJsonReader.java +++ b/src/main/java/cn/kuzuanpa/thinker/client/json/thinkerJsonReader.java @@ -31,10 +31,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class thinkerJsonReader { @@ -56,11 +53,13 @@ public static void readAllProfiles(String path) throws IOException { }); //profileHandler.clearAllProfile(); profileHandler.addProfiles(profileList); + profileHandler.buildDirTree(); } public static profileHandler.thinkingProfile readProfiles(JsonReader json,String profileName)throws IOException,IllegalArgumentException { String id=""; String bindItemID=""; + String[] dir = null; IIcon icon=null; float iconR=1.0F; float iconG=1.0F; @@ -77,6 +76,9 @@ public static profileHandler.thinkingProfile readProfiles(JsonReader json,String icon=getIcon(json.nextString(),json,profileName); }else if (jsonName.equalsIgnoreCase("bindItemID")) { bindItemID = json.nextString(); + }else if (jsonName.equalsIgnoreCase("dir")) { + String str = json.nextString(); + if(!str.equals(""))dir =str.split("/"); } else if (jsonName.equalsIgnoreCase("iconR")) { iconR = (float) json.nextDouble(); } else if (jsonName.equalsIgnoreCase("iconG")) { @@ -103,6 +105,7 @@ public static profileHandler.thinkingProfile readProfiles(JsonReader json,String if(id.equals("")||ThinkerObjects.isEmpty()){logError(json,profileName,"Invaild Profile");return null;} profileHandler.thinkingProfile returnProfile = objs.isEmpty() ? new profileHandler.thinkingProfile(id,icon,iconR,iconG,iconB,iconA,buttons) : new profileHandler.thinkingProfile(id,icon,iconR,iconG,iconB,iconA,objs,buttons); returnProfile.setBindItemId(bindItemID); + if(dir != null&&dir.length>0)returnProfile.setDir(dir); return returnProfile; } public static IIcon getIcon(String iconString, JsonReader json, String fileName){ diff --git a/src/main/java/cn/kuzuanpa/thinker/client/render/gui/ThinkingProfileList.java b/src/main/java/cn/kuzuanpa/thinker/client/render/gui/ThinkingProfileList.java index cd318dc..59266c7 100644 --- a/src/main/java/cn/kuzuanpa/thinker/client/render/gui/ThinkingProfileList.java +++ b/src/main/java/cn/kuzuanpa/thinker/client/render/gui/ThinkingProfileList.java @@ -29,6 +29,7 @@ */ package cn.kuzuanpa.thinker.client.render.gui; +import cn.kuzuanpa.thinker.Thinker; import cn.kuzuanpa.thinker.client.handler.configHandler; import cn.kuzuanpa.thinker.client.handler.profileHandler; import net.minecraft.client.Minecraft; @@ -36,6 +37,9 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + import static cn.kuzuanpa.thinker.Thinker.MOD_ID; public class ThinkingProfileList extends ThinkerButtonBase { @@ -49,28 +53,91 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) { if (!this.visible)return; GL11.glPushMatrix(); GuiAnimeList.forEach(anime->anime.animeDrawPre(timer)); - ResourceLocation buttontextures=new ResourceLocation(MOD_ID,"textures/gui/think/base.png"); - for (int i : profileHandler.displayProfileIDMap.keySet()){ - if(profileHandler.getProfile(profileHandler.displayProfileIDMap.get(i))==null)return; - profileHandler.thinkingProfile profile = profileHandler.getProfile(profileHandler.displayProfileIDMap.get(i)); - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.65F); - mc.getTextureManager().bindTexture(buttontextures); - GuiAnimeList.forEach(anime->anime.animeDraw(timer)); - this.drawTexturedModalRect(0, (int) (Math.floor(profileHandler.YOffset)+i*(16+configHandler.themeSelectorProfileGap.get())), 64, 0, 64, 16); - //Draw select tag - if(profileHandler.selectedProfile!=null&&profileHandler.selectedProfile.id.equals(profile.id))this.drawTexturedModalRect(0, (int) (Math.floor(profileHandler.YOffset)+i*(16+configHandler.themeSelectorProfileGap.get())), 0, 64, 64, 16); - this.drawCenteredString(mc.fontRenderer,profile.id,40, (int) (Math.floor(profileHandler.YOffset)+i*(16+configHandler.themeSelectorProfileGap.get()))+4, 0xffffff); - //if icon==null, return - if(profile.icon==null){GL11.glPopMatrix();continue;} - //draw icon - GL11.glColor4f(profile.iconR,profile.iconG,profile.iconB,profile.iconA); - mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture); - this.drawTexturedModelRectFromIcon(0, (int) (Math.floor(profileHandler.YOffset)+i*(16+configHandler.themeSelectorProfileGap.get())),profile.icon, 16, 16); - GL11.glPopMatrix(); - } + + AtomicInteger i= new AtomicInteger(); + walkMaps(0,profileHandler.rootDir,mc,i,""); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GuiAnimeList.forEach(anime->anime.animeDrawAfter(timer)); GL11.glPopMatrix(); } + public void walkMaps(int depth, Map map,Minecraft mc, AtomicInteger i,String path){ + map.forEach((key,value)->{ + if(!path.equals("")&&!profileHandler.unfoldedDirs.contains(path))return; + if(value instanceof profileHandler.thinkingProfile) { + drawProfileAt(mc,depth*8, (int) (profileHandler.YOffset+i.get()),(profileHandler.thinkingProfile)value,depth); + i.getAndAdd(16+configHandler.themeSelectorProfileGap.getI()); + } + if(value instanceof Map){ + drawDirAt(mc,depth*8, (int) (profileHandler.YOffset+i.get()),key,depth); + i.getAndAdd(16+configHandler.themeSelectorProfileGap.getI()/2); + walkMaps(depth+1,(Map) value,mc,i,path+"/"+key); + } + }); + } + private void drawDirAt(Minecraft mc, int x, int y, String id,int depth){ + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.65F); + ResourceLocation buttontextures=new ResourceLocation(MOD_ID,"textures/gui/think/base.png"); + mc.getTextureManager().bindTexture(buttontextures); + GuiAnimeList.forEach(anime->anime.animeDraw(timer)); + //draw folders tag + for (int j=0;janime.animeDraw(timer)); + this.drawTexturedModalRect(x, y, 64, 0, 64, 16); + //draw folders tag + for (int j=0;j map,Minecraft mc, AtomicInteger i,int mouseY,String path){ + for (Map.Entry entry : map.entrySet()) { + if(!path.equals("")&&!profileHandler.unfoldedDirs.contains(path))return ""; + String key = entry.getKey(); + Object value = entry.getValue(); + if (value instanceof profileHandler.thinkingProfile) { + if (isXYinButton((int) (profileHandler.YOffset + i.get()), mouseY)) return "Profile:"+key; + i.getAndAdd(16 + configHandler.themeSelectorProfileGap.getI()); + } + if (value instanceof Map) { + if (isXYinButton((int) (profileHandler.YOffset + i.get()), mouseY)) return "Dir:"+key; + i.getAndAdd(16 + configHandler.themeSelectorProfileGap.getI() / 2); + String str = searchButtons(depth + 1, (Map) value, mc, i, mouseY,path+"/"+key); + if(str.startsWith("Dir:"))return "Dir:"+key+"/"+str.replaceFirst("Dir:",""); + if(!str.equals(""))return str; + } + } + return ""; + } + public boolean isXYinButton(int buttonY,int mouseY){ + return mouseY>=buttonY&&mouseY<=buttonY+16; + } } diff --git a/src/main/resources/assets/thinker/textures/gui/think/base.png b/src/main/resources/assets/thinker/textures/gui/think/base.png index f5e0fd8..b2aef4b 100644 Binary files a/src/main/resources/assets/thinker/textures/gui/think/base.png and b/src/main/resources/assets/thinker/textures/gui/think/base.png differ diff --git a/src/main/resources/assets/thinker/textures/gui/think/base.png.kra b/src/main/resources/assets/thinker/textures/gui/think/base.png.kra index b6fcb13..e98bdba 100644 Binary files a/src/main/resources/assets/thinker/textures/gui/think/base.png.kra and b/src/main/resources/assets/thinker/textures/gui/think/base.png.kra differ