001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 006 @SideOnly(Side.CLIENT) 007 public class GuiVideoSettings extends GuiScreen 008 { 009 private GuiScreen parentGuiScreen; 010 011 /** The title string that is displayed in the top-center of the screen. */ 012 protected String screenTitle = "Video Settings"; 013 014 /** GUI game settings */ 015 private GameSettings guiGameSettings; 016 017 /** 018 * True if the system is 64-bit (using a simple indexOf test on a system property) 019 */ 020 private boolean is64bit = false; 021 022 /** An array of all of EnumOption's video options. */ 023 private static EnumOptions[] videoOptions = new EnumOptions[] {EnumOptions.GRAPHICS, EnumOptions.RENDER_DISTANCE, EnumOptions.AMBIENT_OCCLUSION, EnumOptions.FRAMERATE_LIMIT, EnumOptions.ANAGLYPH, EnumOptions.VIEW_BOBBING, EnumOptions.GUI_SCALE, EnumOptions.ADVANCED_OPENGL, EnumOptions.GAMMA, EnumOptions.RENDER_CLOUDS, EnumOptions.PARTICLES, EnumOptions.USE_SERVER_TEXTURES}; 024 025 public GuiVideoSettings(GuiScreen par1GuiScreen, GameSettings par2GameSettings) 026 { 027 this.parentGuiScreen = par1GuiScreen; 028 this.guiGameSettings = par2GameSettings; 029 } 030 031 /** 032 * Adds the buttons (and other controls) to the screen in question. 033 */ 034 public void initGui() 035 { 036 StringTranslate var1 = StringTranslate.getInstance(); 037 this.screenTitle = var1.translateKey("options.videoTitle"); 038 int var2 = 0; 039 EnumOptions[] var3 = videoOptions; 040 int var4 = var3.length; 041 int var5; 042 043 for (var5 = 0; var5 < var4; ++var5) 044 { 045 EnumOptions var6 = var3[var5]; 046 047 if (var6.getEnumFloat()) 048 { 049 this.controlList.add(new GuiSlider(var6.returnEnumOrdinal(), this.width / 2 - 155 + var2 % 2 * 160, this.height / 6 + 24 * (var2 >> 1), var6, this.guiGameSettings.getKeyBinding(var6), this.guiGameSettings.getOptionFloatValue(var6))); 050 } 051 else 052 { 053 this.controlList.add(new GuiSmallButton(var6.returnEnumOrdinal(), this.width / 2 - 155 + var2 % 2 * 160, this.height / 6 + 24 * (var2 >> 1), var6, this.guiGameSettings.getKeyBinding(var6))); 054 } 055 056 ++var2; 057 } 058 059 this.controlList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done"))); 060 this.is64bit = false; 061 String[] var9 = new String[] {"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"}; 062 String[] var10 = var9; 063 var5 = var9.length; 064 065 for (int var11 = 0; var11 < var5; ++var11) 066 { 067 String var7 = var10[var11]; 068 String var8 = System.getProperty(var7); 069 070 if (var8 != null && var8.contains("64")) 071 { 072 this.is64bit = true; 073 break; 074 } 075 } 076 } 077 078 /** 079 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). 080 */ 081 protected void actionPerformed(GuiButton par1GuiButton) 082 { 083 if (par1GuiButton.enabled) 084 { 085 int var2 = this.guiGameSettings.guiScale; 086 087 if (par1GuiButton.id < 100 && par1GuiButton instanceof GuiSmallButton) 088 { 089 this.guiGameSettings.setOptionValue(((GuiSmallButton)par1GuiButton).returnEnumOptions(), 1); 090 par1GuiButton.displayString = this.guiGameSettings.getKeyBinding(EnumOptions.getEnumOptions(par1GuiButton.id)); 091 } 092 093 if (par1GuiButton.id == 200) 094 { 095 this.mc.gameSettings.saveOptions(); 096 this.mc.displayGuiScreen(this.parentGuiScreen); 097 } 098 099 if (this.guiGameSettings.guiScale != var2) 100 { 101 ScaledResolution var3 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); 102 int var4 = var3.getScaledWidth(); 103 int var5 = var3.getScaledHeight(); 104 this.setWorldAndResolution(this.mc, var4, var5); 105 } 106 } 107 } 108 109 /** 110 * Draws the screen and all the components in it. 111 */ 112 public void drawScreen(int par1, int par2, float par3) 113 { 114 this.drawDefaultBackground(); 115 this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 20, 16777215); 116 117 if (!this.is64bit && this.guiGameSettings.renderDistance == 0) 118 { 119 this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("options.farWarning1"), this.width / 2, this.height / 6 + 144, 11468800); 120 this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("options.farWarning2"), this.width / 2, this.height / 6 + 144 + 12, 11468800); 121 } 122 123 super.drawScreen(par1, par2, par3); 124 } 125 }