Skip to content

Commit

Permalink
a rocket dev ui for develop AR things
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzuanpa committed Mar 29, 2024
1 parent 4d706a0 commit 0927683
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 8 deletions.
9 changes: 8 additions & 1 deletion src/main/java/cn/kuzuanpa/thinker/client/configHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ public class configHandler {
public static configNumber HUDBackgroundColorG =new configNumber(0,50,255);
public static configNumber HUDBackgroundColorB =new configNumber(0,50,255);
public static configNumber HUDBackgroundColorA =new configNumber(0,200,255);
public static configNumber animeSpeed=new configNumber(0.01F,1.0F,10.0F);
public static configNumber animeSpeed=new configNumber(0.01F,2.0F,10.0F);
public static configBoolean themeSelectorFreelyScroll=new configBoolean(false);
public static configNumber themeSelectorProfileGap =new configNumber(0,4,80);
public static configNumber themeSelectorScrollSpeed =new configNumber(0.01F,1.0F,10.0F);

public static configNumber themeSelectorScrollInertia =new configNumber(0.01F,8F,50.0F);

public static configNumber devRocketStarMass =new configNumber(0,200,1000);
public static configNumber devRocketRocketSpeed =new configNumber(0,0,50);
public static configNumber devRocketRocketAngle =new configNumber(0,200,360);
public static configNumber devRocketRocketSpeedAngle =new configNumber(0,200,360);
public static configNumber devRocketRocketSpeedDelta =new configNumber(0,200,1000);


public static int getConfiguredAnimeTime(int originalTime){return (int) (originalTime*((float)1/animeSpeed.get()));}
public static float getConfiguredAnimeTime(float originalTime){return originalTime*((float)1/animeSpeed.get());}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void initGui() {
buttonList.add(new ThinkerButton(3,5, 45,132,20,l10n("thinker.settings.HUD")) .addAnime(new animeMoveLinear(-1,0,-600,0)).addAnime(new animeMoveLinear(0,configHandler.getConfiguredAnimeTime( 800),600,0)).addToList(buttonsHaveAnime));
buttonList.add(new ThinkerButton(4,5, 70,132,20,l10n("thinker.settings.anime")) .addAnime(new animeMoveLinear(-1,0,-550,0)).addAnime(new animeMoveLinear(0,configHandler.getConfiguredAnimeTime( 900),550,0)).addToList(buttonsHaveAnime));
buttonList.add(new ThinkerButton(5,5, 95,132,20,l10n("thinker.settings.profile_selector")).addAnime(new animeMoveLinear(-1,0,-500,0)).addAnime(new animeMoveLinear(0,configHandler.getConfiguredAnimeTime(1000),500,0)).addToList(buttonsHaveAnime));
buttonList.add(new ThinkerButton(6,5,120,132,20,l10n("thinker.settings.dummy_world")) .addAnime(new animeMoveLinear(-1,0,-500,0)).addAnime(new animeMoveLinear(0,configHandler.getConfiguredAnimeTime(1100),500,0)).addToList(buttonsHaveAnime));
buttonList.add(new ThinkerButton(6,5,120,132,20,l10n("thinker.settings.rocket_dev")) .addAnime(new animeMoveLinear(-1,0,-500,0)).addAnime(new animeMoveLinear(0,configHandler.getConfiguredAnimeTime(1100),500,0)).addToList(buttonsHaveAnime));
buttonList.add(new ThinkerButton(7,5,145,132,20,l10n("thinker.settings.help")) .addAnime(new animeMoveLinear(-1,0,-500,0)).addAnime(new animeMoveLinear(0,configHandler.getConfiguredAnimeTime(1200),500,0)).addToList(buttonsHaveAnime));
buttonList.add(new thinkerImage(8,40,4,64,16,96,32,"textures/gui/think/base.png","").addAnime(new animeTransparency(-1,0,255,-255)).addAnime(new animeTransparency(configHandler.getConfiguredAnimeTime(1100),configHandler.getConfiguredAnimeTime(1800),0,255)).addToList(buttonsHaveAnime));
buttonList.add( new NumberConfigButton(9 ,150,20 ,displayWidth-160,32,"ColorR",configHandler.HUDBackgroundColorR));
Expand All @@ -61,6 +61,12 @@ public void initGui() {
buttonList.add( new NumberConfigButton(15,150,60,displayWidth-160,32,"Profile Gap",configHandler.themeSelectorProfileGap));
buttonList.add( new NumberConfigButton(16,150,100,displayWidth-160,32,"Scroll Inertia",configHandler.themeSelectorScrollInertia));
buttonList.add( new NumberConfigButton(17,150,140,displayWidth-160,32,"Scroll Speed",configHandler.themeSelectorScrollSpeed));
buttonList.add( new NumberConfigButton(18,150,20 ,displayWidth-160,32,"Rocket Angle",configHandler.devRocketRocketAngle));
buttonList.add( new NumberConfigButton(19,150,60 ,displayWidth-160,32,"Rocket Speed",configHandler.devRocketRocketSpeed));
buttonList.add( new NumberConfigButton(20,150,100,displayWidth-160,32,"Rocket Speed Angle",configHandler.devRocketRocketSpeedAngle));
buttonList.add( new NumberConfigButton(21,150,140,displayWidth-160,32,"Rocket Speed Delta",configHandler.devRocketRocketSpeedDelta));
buttonList.add( new NumberConfigButton(22,150,180,displayWidth-160,32,"Star mass",configHandler.devRocketStarMass));
buttonList.add( new devRocketButton(23,150,180,displayWidth-160,32));

if(openByUser)postInitGui();
for (int i = 9; i < buttonList.size(); i++) {
Expand Down Expand Up @@ -98,7 +104,7 @@ protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_)
protected boolean onButtonPressed(GuiButton button) {
if(button.id==1||button.id==2)close();
if(2<button.id&&button.id<9)updateButtonList(button.id);
System.out.println(button.id);
devRocketButton.reset();
return true;
}
private void updateButtonList(int categoryId){
Expand All @@ -111,6 +117,7 @@ private void updateButtonList(int categoryId){
case 3:starti=9;endi=12;break;
case 4:starti=13;endi=13;break;
case 5:starti=14;endi=17;break;
case 6:starti=18;endi=23;break;
default: return;
}
for (int i = starti; i <= endi; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public void initGui() {

HashMap<BlockPosition, dummyWorldBlock> blocks=new HashMap<>();
HashMap<BlockPosition, dummyWorldTileEntity> tiles=new HashMap<>();
tiles.put(new BlockPosition(10,1,1),new dummyWorldTileEntity(TileEntity.createAndLoadEntity((NBTTagCompound) Nbt.stringToNBT("{gt.mte.reg:1042s,gt.output.max:256s,x:10,gt.facing:1b,y:1,z:0,id:\"ktfru.multitileentity.multiblock.sunheater\",gt.mte.id:30007s}"))));
tiles.put(new BlockPosition(1,1,1),new dummyWorldTileEntity(TileEntity.createAndLoadEntity((NBTTagCompound) Nbt.stringToNBT("{gt.target.z:0s,gt.target.y:1b,gt.target.x:10s,gt.mte.reg:1042s,x:1,gt.facing:5b,y:1,z:1,id:\"ktfru.multitileentity.multiblock.sunheater.mirror\",gt.target:1b,gt.mte.id:31001s}"))));

//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.put(new BlockPosition(0,2,0),new dummyWorldBlock(Blocks.dark_oak_stairs,new DummyBlockAnimeRotateSteadily()));
Expand All @@ -108,8 +105,8 @@ public void initGui() {
blocks.put(new BlockPosition(0,2,5),new dummyWorldBlock(Blocks.diamond_block));
blocks.put(new BlockPosition(2,2,0),new dummyWorldBlock(Blocks.stained_glass));
profileHandler.clearAllProfile();
profileHandler.addProfile(new profileHandler.thinkingProfile("test1",Items.string.getIconFromDamage(0),new thinkerImage(12,displayWidth-122,20,0,0,32,32,"textures/gui/think/base.png", l10n("test")).addAnime(new animeRotateSteadily(0.05F)).addToList(buttonsHaveAnime)));
profileHandler.addProfile(new profileHandler.thinkingProfile("test2",Items.string.getIconFromDamage(0),blocks,tiles,new thinkerImage(13,displayWidth-122,20,0,0,32,32,"textures/gui/think/base.png", l10n("test")).addAnime(new animeRotateSteadily(0.05F)).addToList(buttonsHaveAnime)));
profileHandler.addProfile(new profileHandler.thinkingProfile("test1",Items.string.getIconFromDamage(0)));
profileHandler.addProfile(new profileHandler.thinkingProfile("test2",Items.string.getIconFromDamage(0),blocks,tiles,new thinkerImage(13,displayWidth-122,20,0,0,32,32,"textures/gui/think/base.png", l10n("test"))));
try{profileHandler.addProfile(jsonReader.readProfiles("testJson"));}catch (Exception e){e.printStackTrace();}

if(openByUser)postInit();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This class was created by <kuzuanpa>. It is distributed as
* part of the kTFRUAddon Mod. Get the Source Code in github:
* https://github.com/kuzuanpa/kTFRUAddon
*
* kTFRUAddon is Open Source and distributed under the
* LGPLv3 License: https://www.gnu.org/licenses/lgpl-3.0.txt
*
*/

package cn.kuzuanpa.thinker.client.render.gui.button;

import cn.kuzuanpa.thinker.client.configHandler;
import cn.kuzuanpa.thinker.client.render.gui.anime.IGuiAnime;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

import java.util.ArrayList;
import java.util.List;

import static cn.kuzuanpa.thinker.Thinker.MOD_ID;

public class devRocketButton extends ThinkerButton {


public devRocketButton(int id, int x, int y, int w, int h) {
super(id, x, y,w,h,"");
this.id=id;
this.x=x;
this.y=y;
reset();
}
public int id,x,y;
public static float rocketX=228,rocketY=400;
public String path;
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
updateHoverState(mouseX,mouseY);
if (this.visible) {
GL11.glEnable(GL11.GL_BLEND);
mc.getTextureManager().bindTexture(baseTexture);
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
drawTexturedModalRect(328,400,0,0,32,32);

//drawRocket
GL11.glPushMatrix();
GL11.glTranslatef(rocketX+8,rocketY+16,0);
GL11.glRotatef(configHandler.devRocketRocketAngle.get()+180,0,0,1);
GL11.glTranslatef(-8,-16,0);

drawTexturedModalRect(0,0,69,20,16,32);
GL11.glPopMatrix();

updateRocket();
}
}
public static void reset(){
rocketX=228;rocketY=400;
}
public void updateRocket(){
rocketX+= configHandler.devRocketRocketSpeed.get() *Math.cos(3.14*(configHandler.devRocketRocketAngle.get()-90)/180);
rocketY+=configHandler.devRocketRocketSpeed.get() *Math.sin(3.14*(configHandler.devRocketRocketAngle.get()-90)/180);
}
}

0 comments on commit 0927683

Please sign in to comment.