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, EnumOptions.USE_FULLSCREEN, EnumOptions.ENABLE_VSYNC}; 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 this.controlList.clear(); 039 this.controlList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done"))); 040 this.is64bit = false; 041 String[] var2 = new String[] {"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"}; 042 String[] var3 = var2; 043 int var4 = var2.length; 044 045 for (int var5 = 0; var5 < var4; ++var5) 046 { 047 String var6 = var3[var5]; 048 String var7 = System.getProperty(var6); 049 050 if (var7 != null && var7.contains("64")) 051 { 052 this.is64bit = true; 053 break; 054 } 055 } 056 057 int var9 = 0; 058 var4 = this.is64bit ? 0 : -15; 059 EnumOptions[] var10 = videoOptions; 060 int var11 = var10.length; 061 062 for (int var12 = 0; var12 < var11; ++var12) 063 { 064 EnumOptions var8 = var10[var12]; 065 066 if (var8.getEnumFloat()) 067 { 068 this.controlList.add(new GuiSlider(var8.returnEnumOrdinal(), this.width / 2 - 155 + var9 % 2 * 160, this.height / 7 + var4 + 24 * (var9 >> 1), var8, this.guiGameSettings.getKeyBinding(var8), this.guiGameSettings.getOptionFloatValue(var8))); 069 } 070 else 071 { 072 this.controlList.add(new GuiSmallButton(var8.returnEnumOrdinal(), this.width / 2 - 155 + var9 % 2 * 160, this.height / 7 + var4 + 24 * (var9 >> 1), var8, this.guiGameSettings.getKeyBinding(var8))); 073 } 074 075 ++var9; 076 } 077 } 078 079 /** 080 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). 081 */ 082 protected void actionPerformed(GuiButton par1GuiButton) 083 { 084 if (par1GuiButton.enabled) 085 { 086 int var2 = this.guiGameSettings.guiScale; 087 088 if (par1GuiButton.id < 100 && par1GuiButton instanceof GuiSmallButton) 089 { 090 this.guiGameSettings.setOptionValue(((GuiSmallButton)par1GuiButton).returnEnumOptions(), 1); 091 par1GuiButton.displayString = this.guiGameSettings.getKeyBinding(EnumOptions.getEnumOptions(par1GuiButton.id)); 092 } 093 094 if (par1GuiButton.id == 200) 095 { 096 this.mc.gameSettings.saveOptions(); 097 this.mc.displayGuiScreen(this.parentGuiScreen); 098 } 099 100 if (this.guiGameSettings.guiScale != var2) 101 { 102 ScaledResolution var3 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); 103 int var4 = var3.getScaledWidth(); 104 int var5 = var3.getScaledHeight(); 105 this.setWorldAndResolution(this.mc, var4, var5); 106 } 107 } 108 } 109 110 /** 111 * Draws the screen and all the components in it. 112 */ 113 public void drawScreen(int par1, int par2, float par3) 114 { 115 this.drawDefaultBackground(); 116 this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, this.is64bit ? 20 : 5, 16777215); 117 118 if (!this.is64bit && this.guiGameSettings.renderDistance == 0) 119 { 120 this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("options.farWarning1"), this.width / 2, this.height / 6 + 144 + 1, 11468800); 121 this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("options.farWarning2"), this.width / 2, this.height / 6 + 144 + 13, 11468800); 122 } 123 124 super.drawScreen(par1, par2, par3); 125 } 126 }