Java 类net.minecraft.client.gui.GuiSlider 实例源码

项目:DynamicSurroundings    文件:VolumeControlGui.java   
@Override
public void initGui() {
    final int drawX = (this.width + 1) / 2 - SLIDER_WIDTH / 2;
    final int drawY = 40;

    addSlider(new GuiSlider(this, ID_MASTER_SOUND, drawX, drawY, "dlg.name.MasterSound", 0F, 1F, this.master,
            FORMAT));
    addSlider(new GuiSlider(this, ID_BIOME_SOUND, drawX, drawY + 25, "dlg.name.BiomeSound", 0F, 1F, this.biome,
            FORMAT));
    addSlider(new GuiSlider(this, ID_FOOTSTEP_SOUND, drawX, drawY + 50, "dlg.name.FootstepSound", 0F, 1F,
            this.footstep, FORMAT));

    final GuiLabel label = new GuiLabel(mc.fontRenderer, ID_LABEL, drawX, drawY + 75, SLIDER_WIDTH, 10,
            Color.MC_WHITE.rgb());
    label.setCentered().addLine(Localization.format("dlg.name.Close"));
    this.labelList.add(label);

    this.panel.setMinimumWidth(SLIDER_WIDTH + mc.fontRenderer.FONT_HEIGHT * 2);
    this.panel.setMinimumHeight(4 * 25);
}
项目:CreeperHostGui    文件:GuiGeneralServerInfo.java   
@Override
public void initGui()
{
    super.initGui();

    int halfWidth = this.width / 2;
    int halfHeight = this.height / 2;

    this.nameField = new GuiTextFieldValidate(0, this.fontRendererObj, halfWidth - 100, halfHeight - 50, 200, 20, "([A-Za-z0-9]*)");
    this.nameField.setMaxStringLength(Constants.MAX_SERVER_NAME_LENGTH);
    this.nameField.setText(this.order.name.isEmpty() ? Util.getDefaultName() : this.order.name);
    this.order.name = this.nameField.getText().trim();

    String checkboxString = Util.localize("info.pregen");

    int checkboxWidth = this.fontRendererObj.getStringWidth(checkboxString) + 11 + 2;

    pregen = new GuiCheckBox(3, halfWidth - (checkboxWidth / 2), halfHeight - 8, checkboxString, order.pregen);

    if (Config.getInstance().getPregenDiameter() > 0)
    {
        this.buttonList.add(pregen);
    }

    this.slotSlider = new GuiSlider(this, 1, halfWidth - 100, halfHeight + 15, Util.localize("slider.player_count"), Constants.MIN_PLAYER_COUNT, Constants.MAX_PLAYER_COUNT, this.order.playerAmount, SLIDER_FORMATTER);
    this.slotSlider.width = 200;
    this.buttonList.add(this.slotSlider);
}
项目:RuneCraftery    文件:GuiOptions.java   
public void func_73866_w_() {
   int var1 = 0;
   this.field_74054_a = I18n.func_135053_a("options.title");
   EnumOptions[] var2 = field_74052_b;
   int var3 = var2.length;

   for(int var4 = 0; var4 < var3; ++var4) {
      EnumOptions var5 = var2[var4];
      if(var5.func_74380_a()) {
         this.field_73887_h.add(new GuiSlider(var5.func_74381_c(), this.field_73880_f / 2 - 155 + var1 % 2 * 160, this.field_73881_g / 6 - 12 + 24 * (var1 >> 1), var5, this.field_74051_d.func_74297_c(var5), this.field_74051_d.func_74296_a(var5)));
      } else {
         GuiSmallButton var6 = new GuiSmallButton(var5.func_74381_c(), this.field_73880_f / 2 - 155 + var1 % 2 * 160, this.field_73881_g / 6 - 12 + 24 * (var1 >> 1), var5, this.field_74051_d.func_74297_c(var5));
         if(var5 == EnumOptions.DIFFICULTY && this.field_73882_e.field_71441_e != null && this.field_73882_e.field_71441_e.func_72912_H().func_76093_s()) {
            var6.field_73742_g = false;
            var6.field_73744_e = I18n.func_135053_a("options.difficulty") + ": " + I18n.func_135053_a("options.difficulty.hardcore");
         }

         this.field_73887_h.add(var6);
      }

      ++var1;
   }

   this.field_73887_h.add(new GuiButton(101, this.field_73880_f / 2 - 152, this.field_73881_g / 6 + 96 - 6, 150, 20, I18n.func_135053_a("options.video")));
   this.field_73887_h.add(new GuiButton(100, this.field_73880_f / 2 + 2, this.field_73881_g / 6 + 96 - 6, 150, 20, I18n.func_135053_a("options.controls")));
   this.field_73887_h.add(new GuiButton(102, this.field_73880_f / 2 - 152, this.field_73881_g / 6 + 120 - 6, 150, 20, I18n.func_135053_a("options.language")));
   this.field_73887_h.add(new GuiButton(103, this.field_73880_f / 2 + 2, this.field_73881_g / 6 + 120 - 6, 150, 20, I18n.func_135053_a("options.multiplayer.title")));
   this.field_73887_h.add(new GuiButton(105, this.field_73880_f / 2 - 152, this.field_73881_g / 6 + 144 - 6, 150, 20, I18n.func_135053_a("options.resourcepack")));
   this.field_73887_h.add(new GuiButton(104, this.field_73880_f / 2 + 2, this.field_73881_g / 6 + 144 - 6, 150, 20, I18n.func_135053_a("options.snooper.view")));
   this.field_73887_h.add(new GuiButton(200, this.field_73880_f / 2 - 100, this.field_73881_g / 6 + 168, I18n.func_135053_a("gui.done")));
}
项目:RuneCraftery    文件:GuiVideoSettings.java   
public void func_73866_w_() {
   this.field_74107_a = I18n.func_135053_a("options.videoTitle");
   this.field_73887_h.clear();
   this.field_73887_h.add(new GuiButton(200, this.field_73880_f / 2 - 100, this.field_73881_g / 6 + 168, I18n.func_135053_a("gui.done")));
   this.field_74104_d = false;
   String[] var1 = new String[]{"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"};
   String[] var2 = var1;
   int var3 = var1.length;

   for(int var4 = 0; var4 < var3; ++var4) {
      String var5 = var2[var4];
      String var6 = System.getProperty(var5);
      if(var6 != null && var6.contains("64")) {
         this.field_74104_d = true;
         break;
      }
   }

   int var8 = 0;
   var3 = this.field_74104_d?0:-15;
   EnumOptions[] var9 = field_74108_m;
   int var10 = var9.length;

   for(int var11 = 0; var11 < var10; ++var11) {
      EnumOptions var7 = var9[var11];
      if(var7.func_74380_a()) {
         this.field_73887_h.add(new GuiSlider(var7.func_74381_c(), this.field_73880_f / 2 - 155 + var8 % 2 * 160, this.field_73881_g / 7 + var3 + 24 * (var8 >> 1), var7, this.field_74106_c.func_74297_c(var7), this.field_74106_c.func_74296_a(var7)));
      } else {
         this.field_73887_h.add(new GuiSmallButton(var7.func_74381_c(), this.field_73880_f / 2 - 155 + var8 % 2 * 160, this.field_73881_g / 7 + var3 + 24 * (var8 >> 1), var7, this.field_74106_c.func_74297_c(var7)));
      }

      ++var8;
   }

}
项目:Simple-Dimensions    文件:GuiCustomizeDimension.java   
@Override
public void setEntryValue(int p_175319_1_, String p_175319_2_)
   {
       float f = 0.0F;

       try
       {
           f = Float.parseFloat(p_175319_2_);
       }
       catch (NumberFormatException numberformatexception)
       {
           ;
       }

       float f1 = 0.0F;

       switch (p_175319_1_)
       {
           case 132:
               f1 = this.field_175336_F.mainNoiseScaleX = MathHelper.clamp(f, 1.0F, 5000.0F);
               break;
           case 133:
               f1 = this.field_175336_F.mainNoiseScaleY = MathHelper.clamp(f, 1.0F, 5000.0F);
               break;
           case 134:
               f1 = this.field_175336_F.mainNoiseScaleZ = MathHelper.clamp(f, 1.0F, 5000.0F);
               break;
           case 135:
               f1 = this.field_175336_F.depthNoiseScaleX = MathHelper.clamp(f, 1.0F, 2000.0F);
               break;
           case 136:
               f1 = this.field_175336_F.depthNoiseScaleZ = MathHelper.clamp(f, 1.0F, 2000.0F);
               break;
           case 137:
               f1 = this.field_175336_F.depthNoiseScaleExponent = MathHelper.clamp(f, 0.01F, 20.0F);
               break;
           case 138:
               f1 = this.field_175336_F.baseSize = MathHelper.clamp(f, 1.0F, 25.0F);
               break;
           case 139:
               f1 = this.field_175336_F.coordinateScale = MathHelper.clamp(f, 1.0F, 6000.0F);
               break;
           case 140:
               f1 = this.field_175336_F.heightScale = MathHelper.clamp(f, 1.0F, 6000.0F);
               break;
           case 141:
               f1 = this.field_175336_F.stretchY = MathHelper.clamp(f, 0.01F, 50.0F);
               break;
           case 142:
               f1 = this.field_175336_F.upperLimitScale = MathHelper.clamp(f, 1.0F, 5000.0F);
               break;
           case 143:
               f1 = this.field_175336_F.lowerLimitScale = MathHelper.clamp(f, 1.0F, 5000.0F);
               break;
           case 144:
               f1 = this.field_175336_F.biomeDepthWeight = MathHelper.clamp(f, 1.0F, 20.0F);
               break;
           case 145:
               f1 = this.field_175336_F.biomeDepthOffset = MathHelper.clamp(f, 0.0F, 20.0F);
               break;
           case 146:
               f1 = this.field_175336_F.biomeScaleWeight = MathHelper.clamp(f, 1.0F, 20.0F);
               break;
           case 147:
               f1 = this.field_175336_F.biomeScaleOffset = MathHelper.clamp(f, 0.0F, 20.0F);
       }

       if (f1 != f && f != 0.0F)
       {
           ((GuiTextField)this.field_175349_r.getComponent(p_175319_1_)).setText(this.func_175330_b(p_175319_1_, f1));
       }

       ((GuiSlider)this.field_175349_r.getComponent(p_175319_1_ - 132 + 100)).setSliderValue(f1, false);

       if (!this.field_175336_F.equals(this.field_175334_E))
       {
           this.field_175338_A = true;
       }
   }
项目:Simple-Dimensions    文件:GuiCustomizeDimension.java   
@Override
protected void actionPerformed(GuiButton button) throws IOException
   {
       if (button.enabled)
       {
           switch (button.id)
           {
               case 300:
                   this.field_175343_i.chunkProviderSettingsJson = this.field_175336_F.toString();
                   this.mc.displayGuiScreen(this.field_175343_i);
                   break;
               case 301:
                   for (int i = 0; i < this.field_175349_r.getSize(); ++i)
                   {
                       GuiPageButtonList.GuiEntry guientry = this.field_175349_r.getListEntry(i);
                       Gui gui = guientry.getComponent1();

                       if (gui instanceof GuiButton)
                       {
                           GuiButton guibutton1 = (GuiButton)gui;

                           if (guibutton1 instanceof GuiSlider)
                           {
                               float f = ((GuiSlider)guibutton1).getSliderPosition() * (0.75F + this.random.nextFloat() * 0.5F) + (this.random.nextFloat() * 0.1F - 0.05F);
                               ((GuiSlider)guibutton1).setSliderPosition(MathHelper.clamp(f, 0.0F, 1.0F));
                           }
                           else if (guibutton1 instanceof GuiListButton)
                           {
                               ((GuiListButton)guibutton1).setValue(this.random.nextBoolean());
                           }
                       }

                       Gui gui1 = guientry.getComponent2();

                       if (gui1 instanceof GuiButton)
                       {
                           GuiButton guibutton2 = (GuiButton)gui1;

                           if (guibutton2 instanceof GuiSlider)
                           {
                               float f1 = ((GuiSlider)guibutton2).getSliderPosition() * (0.75F + this.random.nextFloat() * 0.5F) + (this.random.nextFloat() * 0.1F - 0.05F);
                               ((GuiSlider)guibutton2).setSliderPosition(MathHelper.clamp(f1, 0.0F, 1.0F));
                           }
                           else if (guibutton2 instanceof GuiListButton)
                           {
                               ((GuiListButton)guibutton2).setValue(this.random.nextBoolean());
                           }
                       }
                   }

                   return;
               case 302:
                   this.field_175349_r.previousPage();
                   this.func_175328_i();
                   break;
               case 303:
                   this.field_175349_r.nextPage();
                   this.func_175328_i();
                   break;
               case 304:
                   if (this.field_175338_A)
                   {
                       this.func_175322_b(304);
                   }

                   break;
               case 305:
                   this.mc.displayGuiScreen(new GuiScreenCustomizeDimensionPresets(this)); 
                   break;
               case 306:
                   this.func_175331_h();
                   break;
               case 307:
                   this.field_175339_B = 0;
                   this.func_175331_h();
           }
       }
   }
项目:DynamicSurroundings    文件:VolumeControlGui.java   
private void addSlider(final GuiSlider slider) {
    slider.setWidth(SLIDER_WIDTH);
    addButton(slider);
}
项目:RuneCraftery    文件:ScreenChatOptions.java   
public void func_73866_w_() {
   int var1 = 0;
   this.field_73888_d = I18n.func_135053_a("options.chat.title");
   this.field_82268_n = I18n.func_135053_a("options.multiplayer.title");
   EnumOptions[] var2 = field_73891_a;
   int var3 = var2.length;

   int var4;
   EnumOptions var5;
   for(var4 = 0; var4 < var3; ++var4) {
      var5 = var2[var4];
      if(var5.func_74380_a()) {
         this.field_73887_h.add(new GuiSlider(var5.func_74381_c(), this.field_73880_f / 2 - 155 + var1 % 2 * 160, this.field_73881_g / 6 + 24 * (var1 >> 1), var5, this.field_73890_c.func_74297_c(var5), this.field_73890_c.func_74296_a(var5)));
      } else {
         this.field_73887_h.add(new GuiSmallButton(var5.func_74381_c(), this.field_73880_f / 2 - 155 + var1 % 2 * 160, this.field_73881_g / 6 + 24 * (var1 >> 1), var5, this.field_73890_c.func_74297_c(var5)));
      }

      ++var1;
   }

   if(var1 % 2 == 1) {
      ++var1;
   }

   this.field_82269_o = this.field_73881_g / 6 + 24 * (var1 >> 1);
   var1 += 2;
   var2 = field_82267_b;
   var3 = var2.length;

   for(var4 = 0; var4 < var3; ++var4) {
      var5 = var2[var4];
      if(var5.func_74380_a()) {
         this.field_73887_h.add(new GuiSlider(var5.func_74381_c(), this.field_73880_f / 2 - 155 + var1 % 2 * 160, this.field_73881_g / 6 + 24 * (var1 >> 1), var5, this.field_73890_c.func_74297_c(var5), this.field_73890_c.func_74296_a(var5)));
      } else {
         this.field_73887_h.add(new GuiSmallButton(var5.func_74381_c(), this.field_73880_f / 2 - 155 + var1 % 2 * 160, this.field_73881_g / 6 + 24 * (var1 >> 1), var5, this.field_73890_c.func_74297_c(var5)));
      }

      ++var1;
   }

   this.field_73887_h.add(new GuiButton(200, this.field_73880_f / 2 - 100, this.field_73881_g / 6 + 168, I18n.func_135053_a("gui.done")));
}
项目:Laser-Level    文件:GuiMarkerEdit.java   
@Override
public void initGui() {
    super.initGui();

    final int centerX = this.width / 2;
    final int centerY = this.height / 2;
    final int nfOffsetX = 25;
    final int nfHeight = 20;
    int id = -1;

    this.nfMarkerLength = new GuiNumericField(this.mc.fontRenderer, ++id, centerX + nfOffsetX, centerY - nfHeight / 2 - (nfHeight + 5) * 4);
    this.buttonList.add(this.nfMarkerLength);

    this.nfX = new GuiNumericField(this.mc.fontRenderer, ++id, centerX + nfOffsetX, centerY - nfHeight / 2 - (nfHeight + 5) * 3);
    this.buttonList.add(this.nfX);

    this.nfY = new GuiNumericField(this.mc.fontRenderer, ++id, centerX + nfOffsetX, centerY - nfHeight / 2 - (nfHeight + 5) * 2);
    this.buttonList.add(this.nfY);

    this.nfZ = new GuiNumericField(this.mc.fontRenderer, ++id, centerX + nfOffsetX, centerY - nfHeight / 2 - (nfHeight + 5) * 1);
    this.buttonList.add(this.nfZ);

    final int sliderWidth = 250;
    final int sliderHeight = 20;

    this.sliderSpacing = new GuiSlider(this.guiResponder, ++id, centerX - sliderWidth / 2, centerY - sliderHeight / 2 + (sliderHeight + 5) * 0, I18n.format(Names.Gui.GuiMarkerEdit.SPACING), 1.0f, 128.0f, this.marker.spacing, this.formatValue);
    this.sliderSpacing.width = sliderWidth;
    this.buttonList.add(this.sliderSpacing);

    this.sliderR = new GuiSlider(this.guiResponder, ++id, centerX - sliderWidth / 2, centerY - sliderHeight / 2 + (sliderHeight + 5) * 1, I18n.format(Names.Gui.GuiMarkerEdit.RED), 0, 255, this.marker.getRed(), this.formatValue);
    this.sliderR.width = sliderWidth;
    this.buttonList.add(this.sliderR);

    this.sliderG = new GuiSlider(this.guiResponder, ++id, centerX - sliderWidth / 2, centerY - sliderHeight / 2 + (sliderHeight + 5) * 2, I18n.format(Names.Gui.GuiMarkerEdit.GREEN), 0, 255, this.marker.getGreen(), this.formatValue);
    this.sliderG.width = sliderWidth;
    this.buttonList.add(this.sliderG);

    this.sliderB = new GuiSlider(this.guiResponder, ++id, centerX - sliderWidth / 2, centerY - sliderHeight / 2 + (sliderHeight + 5) * 3, I18n.format(Names.Gui.GuiMarkerEdit.BLUE), 0, 255, this.marker.getBlue(), this.formatValue);
    this.sliderB.width = sliderWidth;
    this.buttonList.add(this.sliderB);

    final EnumFacing[] sides = new EnumFacing[] {
            EnumFacing.WEST, EnumFacing.EAST, EnumFacing.DOWN, EnumFacing.UP, EnumFacing.NORTH, EnumFacing.SOUTH
    };

    final int cbBaseOffsetX = -120;
    for (int i = 0; i < sides.length; i++) {
        final EnumFacing side = sides[i];
        final int cbOffsetX = side.ordinal() % 2 == 0 ? 0 : 60;
        final int cbHeight = 20;

        this.checkBoxes[side.ordinal()] = new GuiCheckBox(++id, centerX + cbBaseOffsetX + cbOffsetX, centerY + (cbHeight + 5) * (i / 2 - 3) - 5, I18n.format(Names.Gui.GuiMarkerEdit.SIDE_BASE + side.getName()), this.marker.isEnabled(side));
        this.buttonList.add(this.checkBoxes[side.ordinal()]);
    }

    this.btnToggle = new GuiButton(++id, centerX - 4 - 150, this.height - 25, 100, 20, I18n.format(this.marker.enabled ? Names.Gui.GuiMarkerEdit.ON : Names.Gui.GuiMarkerEdit.OFF));
    this.buttonList.add(this.btnToggle);

    this.btnMove = new GuiButton(++id, centerX - 50, this.height - 25, 100, 20, I18n.format(Names.Gui.GuiMarkers.MOVE));
    this.buttonList.add(this.btnMove);

    this.btnDone = new GuiButton(++id, centerX + 4 + 50, this.height - 25, 100, 20, I18n.format(Names.Gui.GuiMarkers.DONE));
    this.buttonList.add(this.btnDone);

    this.nfMarkerLength.setMinimum(0);
    this.nfMarkerLength.setMaximum(Constants.Rendering.MAX_LENGTH);
    this.nfX.setMinimum(Constants.World.MINIMUM_COORD);
    this.nfX.setMaximum(Constants.World.MAXIMUM_COORD);
    this.nfY.setMinimum(Constants.World.MINIMUM_COORD);
    this.nfY.setMaximum(Constants.World.MAXIMUM_COORD);
    this.nfZ.setMinimum(Constants.World.MINIMUM_COORD);
    this.nfZ.setMaximum(Constants.World.MAXIMUM_COORD);

    this.nfMarkerLength.setValue(this.marker.markerLength);
    this.nfX.setValue(this.marker.pos.x);
    this.nfY.setValue(this.marker.pos.y);
    this.nfZ.setValue(this.marker.pos.z);

    updateButtons();
}