public override void Init() { base.Init(); INetworkProcessor network = game.Network; widgets = new Widget[] { // Column 1 !network.IsSinglePlayer ? null : Make(-140, -100, "Click distance", OnWidgetClick, g => g.LocalPlayer.ReachDistance.ToString(), (g, v) => g.LocalPlayer.ReachDistance = Single.Parse(v)), Make(-140, -50, "Music", OnWidgetClick, g => g.UseMusic ? "yes" : "no", (g, v) => { g.UseMusic = v == "yes"; g.AudioPlayer.SetMusic(g.UseMusic); Options.Set(OptionsKey.UseMusic, v == "yes"); }), Make(-140, 0, "Sound", OnWidgetClick, g => g.UseSound ? "yes" : "no", (g, v) => { g.UseSound = v == "yes"; g.AudioPlayer.SetSound(g.UseSound); Options.Set(OptionsKey.UseSound, v == "yes"); }), Make(-140, 50, "View bobbing", OnWidgetClick, g => g.ViewBobbing ? "yes" : "no", (g, v) => { g.ViewBobbing = v == "yes"; Options.Set(OptionsKey.ViewBobbing, v == "yes"); }), // Column 2 !network.IsSinglePlayer ? null : Make(140, -100, "Block physics", OnWidgetClick, g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", (g, v) => { ((SinglePlayerServer)network).physics.Enabled = v == "yes"; Options.Set(OptionsKey.SingleplayerPhysics, v == "yes"); }), Make(140, -50, "Auto close launcher", OnWidgetClick, g => Options.GetBool(OptionsKey.AutoCloseLauncher, false) ? "yes" : "no", (g, v) => Options.Set(OptionsKey.AutoCloseLauncher, v == "yes")), Make(140, 0, "Invert mouse", OnWidgetClick, g => g.InvertMouse ? "yes" : "no", (g, v) => { g.InvertMouse = v == "yes"; Options.Set(OptionsKey.InvertMouse, v == "yes"); }), Make(140, 50, "Mouse sensitivity", OnWidgetClick, g => g.MouseSensitivity.ToString(), (g, v) => { g.MouseSensitivity = Int32.Parse(v); Options.Set(OptionsKey.Sensitivity, v); }), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new OptionsGroupScreen(g))), null, null, }; MakeValidators(); MakeDescriptions(); }
void MakeValidators() { INetworkProcessor network = game.Network; validators = new MenuInputValidator[] { new EnumValidator(), new IntegerValidator(16, 4096), new EnumValidator(), new EnumValidator(), }; }
void MakeValidators() { INetworkProcessor network = game.Network; validators = new MenuInputValidator[] { network.IsSinglePlayer ? new RealValidator(1, 1024) : null, new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), network.IsSinglePlayer ? new BooleanValidator() : null, new BooleanValidator(), new BooleanValidator(), new IntegerValidator(1, 100), }; }
public override void Init() { base.Init(); INetworkProcessor network = game.Network; widgets = new Widget[] { Make(-140, 0, "FPS limit mode", OnWidgetClick, g => g.FpsLimit.ToString(), (g, v) => { object raw = Enum.Parse(typeof(FpsLimitMethod), v); g.SetFpsLimitMethod((FpsLimitMethod)raw); Options.Set(OptionsKey.FpsLimit, v); }), Make(-140, 50, "View distance", OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance(Int32.Parse(v), true)), Make(140, 0, "Names mode", OnWidgetClick, g => g.Players.NamesMode.ToString(), (g, v) => { object raw = Enum.Parse(typeof(NameMode), v); g.Players.NamesMode = (NameMode)raw; Options.Set(OptionsKey.NamesMode, v); }), Make(140, 50, "Entity shadows", OnWidgetClick, g => g.Players.ShadowMode.ToString(), (g, v) => { object raw = Enum.Parse(typeof(EntityShadow), v); g.Players.ShadowMode = (EntityShadow)raw; Options.Set(OptionsKey.EntityShadow, v); }), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new OptionsGroupScreen(g))), null, null, }; widgets[0].Metadata = typeof(FpsLimitMethod); widgets[2].Metadata = typeof(NameMode); widgets[3].Metadata = typeof(EntityShadow); MakeValidators(); MakeDescriptions(); }
protected override void OnLoad( EventArgs e ) { #if !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api( this ); #endif try { Options.Load(); } catch( IOException ) { Utils.LogWarning( "Unable to load options.txt" ); } ViewDistance = Options.GetInt( "viewdist", 16, 8192, 512 ); Keys = new KeyMap(); InputHandler = new InputHandler( this ); Chat = new ChatLog( this ); Drawer2D = new GdiPlusDrawer2D( Graphics ); defaultIb = Graphics.MakeDefaultIb(); ModelCache = new ModelCache( this ); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader( skinServer ); Graphics.PrintGraphicsInfo(); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); Animations = new Animations( this ); TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract( defaultTexPack, this ); Inventory = new Inventory( this ); BlockInfo = new BlockInfo(); BlockInfo.Init(); BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete ); Map = new Map( this ); LocalPlayer = new LocalPlayer( this ); Players[255] = LocalPlayer; width = Width; height = Height; MapRenderer = new MapRenderer( this ); MapEnvRenderer = new MapEnvRenderer( this ); EnvRenderer = new StandardEnvRenderer( this ); if( IPAddress == null ) { Network = new Singleplayer.SinglePlayerServer( this ); } else { Network = new NetworkProcessor( this ); } Graphics.LostContextFunction = Network.Tick; firstPersonCam = new FirstPersonCamera( this ); thirdPersonCam = new ThirdPersonCamera( this ); Camera = firstPersonCam; CommandManager = new CommandManager(); CommandManager.Init( this ); SelectionManager = new SelectionManager( this ); ParticleManager = new ParticleManager( this ); WeatherRenderer = new WeatherRenderer( this ); WeatherRenderer.Init(); Graphics.SetVSync( this, true ); Graphics.DepthTest = true; Graphics.DepthTestFunc( CompareFunc.LessEqual ); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha ); Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f ); Title = Utils.AppName; fpsScreen = new FpsScreen( this ); fpsScreen.Init(); Culling = new FrustumCulling(); EnvRenderer.Init(); MapEnvRenderer.Init(); Picking = new PickingRenderer( this ); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) ); Network.Connect( IPAddress, Port ); }
public override void Init() { base.Init(); INetworkProcessor network = game.Network; buttons = new ButtonWidget[] { // Column 1 Make(-140, -150, "Block in hand", OnWidgetClick, g => g.ShowBlockInHand ? "yes" : "no", (g, v) => { g.ShowBlockInHand = v == "yes"; Options.Set(OptionsKey.ShowBlockInHand, v == "yes"); }), Make(-140, -100, "Show FPS", OnWidgetClick, g => g.ShowFPS ? "yes" : "no", (g, v) => g.ShowFPS = v == "yes"), Make(-140, -50, "Hud scale", OnWidgetClick, g => g.HudScale.ToString(), (g, v) => { g.HudScale = Single.Parse(v); Options.Set(OptionsKey.HudScale, v); g.RefreshHud(); }), Make(-140, 0, "Use classic gui", OnWidgetClick, g => g.UseClassicGui ? "yes" : "no", (g, v) => { g.UseClassicGui = v == "yes"; Options.Set(OptionsKey.UseClassicGui, v == "yes"); }), // Column 2 Make(140, -150, "Clickable chat", OnWidgetClick, g => g.ClickableChat ? "yes" : "no", (g, v) => { g.ClickableChat = v == "yes"; Options.Set(OptionsKey.ClickableChat, v == "yes"); }), Make(140, -100, "Chat scale", OnWidgetClick, g => g.ChatScale.ToString(), (g, v) => { g.ChatScale = Single.Parse(v); Options.Set(OptionsKey.ChatScale, v); g.RefreshHud(); }), Make(140, -50, "Chat lines", OnWidgetClick, g => g.ChatLines.ToString(), (g, v) => { g.ChatLines = Int32.Parse(v); Options.Set(OptionsKey.ChatLines, v); g.RefreshHud(); }), Make(140, 0, "Arial chat font", OnWidgetClick, g => g.Drawer2D.UseBitmappedChat ? "no" : "yes", (g, v) => { g.Drawer2D.UseBitmappedChat = v == "no"; Options.Set(OptionsKey.ArialChatFont, v == "yes"); game.Events.RaiseChatFontChanged(); g.RefreshHud(); Recreate(); }), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new PauseScreen(g))), null, }; validators = new MenuInputValidator[] { new BooleanValidator(), new BooleanValidator(), new RealValidator(0.25f, 5f), new BooleanValidator(), new BooleanValidator(), new RealValidator(0.25f, 5f), new IntegerValidator(1, 30), new BooleanValidator(), }; okayIndex = buttons.Length - 1; }
protected override void OnLoad( EventArgs e ) { #if !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api( this ); #endif Graphics.MakeGraphicsInfo(); Options.Load(); ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 ); InputHandler = new InputHandler( this ); Chat = new ChatLog( this ); Chat.FontSize = Options.GetInt( OptionsKey.FontSize, 6, 30, 12 ); defaultIb = Graphics.MakeDefaultIb(); MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 ); BlockInfo = new BlockInfo(); BlockInfo.Init(); ChatLines = Options.GetInt( OptionsKey.ChatLines, 1, 30, 12 ); ModelCache = new ModelCache( this ); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader( skinServer ); Drawer2D = new GdiPlusDrawer2D( Graphics ); Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false ); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); Animations = new Animations( this ); TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract( defaultTexPack, this ); Inventory = new Inventory( this ); BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete ); Map = new Map( this ); LocalPlayer = new LocalPlayer( this ); LocalPlayer.SpeedMultiplier = Options.GetInt( OptionsKey.Speed, 1, 50, 10 ); Players[255] = LocalPlayer; width = Width; height = Height; MapRenderer = new MapRenderer( this ); MapEnvRenderer = new MapEnvRenderer( this ); EnvRenderer = new StandardEnvRenderer( this ); if( IPAddress == null ) { Network = new Singleplayer.SinglePlayerServer( this ); } else { Network = new NetworkProcessor( this ); } Graphics.LostContextFunction = Network.Tick; firstPersonCam = new FirstPersonCamera( this ); thirdPersonCam = new ThirdPersonCamera( this ); forwardThirdPersonCam = new ForwardThirdPersonCamera( this ); Camera = firstPersonCam; CommandManager = new CommandManager(); CommandManager.Init( this ); SelectionManager = new SelectionManager( this ); ParticleManager = new ParticleManager( this ); WeatherRenderer = new WeatherRenderer( this ); WeatherRenderer.Init(); bool vsync = Options.GetBool( OptionsKey.VSync, true ); Graphics.SetVSync( this, vsync ); Graphics.DepthTest = true; Graphics.DepthTestFunc( CompareFunc.LessEqual ); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha ); Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f ); fpsScreen = new FpsScreen( this ); fpsScreen.Init(); Culling = new FrustumCulling(); EnvRenderer.Init(); MapEnvRenderer.Init(); Picking = new PickingRenderer( this ); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; Graphics.WarnIfNecessary( Chat ); SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) ); Network.Connect( IPAddress, Port ); }
public override void Init() { base.Init(); INetworkProcessor network = game.Network; buttons = new ButtonWidget[] { // Column 1 !network.IsSinglePlayer ? null : Make(-140, -200, "Click distance", OnWidgetClick, g => g.LocalPlayer.ReachDistance.ToString(), (g, v) => g.LocalPlayer.ReachDistance = Single.Parse(v)), Make(-140, -150, "Use sound", OnWidgetClick, g => g.UseSound ? "yes" : "no", (g, v) => { g.UseSound = v == "yes"; g.AudioPlayer.SetSound(g.UseSound); Options.Set(OptionsKey.UseSound, v == "yes"); }), Make(-140, -100, "Simple arms anim", OnWidgetClick, g => g.SimpleArmsAnim? "yes" : "no", (g, v) => { g.SimpleArmsAnim = v == "yes"; Options.Set(OptionsKey.SimpleArmsAnim, v == "yes"); }), Make(-140, -50, "Names mode", OnWidgetClick, g => g.Players.NamesMode.ToString(), (g, v) => { object raw = Enum.Parse(typeof(NameMode), v); g.Players.NamesMode = (NameMode)raw; Options.Set(OptionsKey.NamesMode, v); }), Make(-140, 0, "FPS limit", OnWidgetClick, g => g.FpsLimit.ToString(), (g, v) => { object raw = Enum.Parse(typeof(FpsLimitMethod), v); g.SetFpsLimitMethod((FpsLimitMethod)raw); Options.Set(OptionsKey.FpsLimit, v); }), Make(-140, 50, "View distance", OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance(Int32.Parse(v), true)), // Column 2 !network.IsSinglePlayer ? null : Make(140, -200, "Block physics", OnWidgetClick, g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", (g, v) => { ((SinglePlayerServer)network).physics.Enabled = v == "yes"; Options.Set(OptionsKey.SingleplayerPhysics, v == "yes"); }), Make(140, -150, "Use music", OnWidgetClick, g => g.UseMusic ? "yes" : "no", (g, v) => { g.UseMusic = v == "yes"; g.AudioPlayer.SetMusic(g.UseMusic); Options.Set(OptionsKey.UseMusic, v == "yes"); }), Make(140, -100, "View bobbing", OnWidgetClick, g => g.ViewBobbing ? "yes" : "no", (g, v) => { g.ViewBobbing = v == "yes"; Options.Set(OptionsKey.ViewBobbing, v == "yes"); }), Make(140, -50, "Auto close launcher", OnWidgetClick, g => Options.GetBool(OptionsKey.AutoCloseLauncher, false) ? "yes" : "no", (g, v) => Options.Set(OptionsKey.AutoCloseLauncher, v == "yes")), Make(140, 0, "Invert mouse", OnWidgetClick, g => g.InvertMouse ? "yes" : "no", (g, v) => { g.InvertMouse = v == "yes"; Options.Set(OptionsKey.InvertMouse, v == "yes"); }), Make(140, 50, "Mouse sensitivity", OnWidgetClick, g => g.MouseSensitivity.ToString(), (g, v) => { g.MouseSensitivity = Int32.Parse(v); Options.Set(OptionsKey.Sensitivity, v); }), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new PauseScreen(g))), null, }; buttons[3].Metadata = typeof(NameMode); buttons[4].Metadata = typeof(FpsLimitMethod); validators = new MenuInputValidator[] { network.IsSinglePlayer ? new RealValidator(1, 1024) : null, new BooleanValidator(), new BooleanValidator(), new EnumValidator(), new EnumValidator(), new IntegerValidator(16, 4096), network.IsSinglePlayer ? new BooleanValidator() : null, new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), new IntegerValidator(1, 100), }; okayIndex = buttons.Length - 1; }
public override void Init() { base.Init(); INetworkProcessor network = game.Network; buttons = new ButtonWidget[] { // Column 1 Make(-140, -100, "Hacks enabled", OnWidgetClick, g => g.LocalPlayer.HacksEnabled ? "yes" : "no", (g, v) => { g.LocalPlayer.HacksEnabled = v == "yes"; Options.Set(OptionsKey.HacksEnabled, v == "yes"); g.LocalPlayer.CheckHacksConsistency(); }), Make(-140, -50, "Speed multiplier", OnWidgetClick, g => g.LocalPlayer.SpeedMultiplier.ToString(), (g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse(v); Options.Set(OptionsKey.Speed, v); }), Make(-140, 0, "Camera clipping", OnWidgetClick, g => g.CameraClipping ? "yes" : "no", (g, v) => { g.CameraClipping = v == "yes"; Options.Set(OptionsKey.CameraClipping, v == "yes"); }), Make(-140, 50, "Jump height", OnWidgetClick, g => g.LocalPlayer.JumpHeight.ToString(), (g, v) => g.LocalPlayer.CalculateJumpVelocity(Single.Parse(v))), // Column 2 Make(140, -100, "Liquids breakable", OnWidgetClick, g => g.LiquidsBreakable ? "yes" : "no", (g, v) => { g.LiquidsBreakable = v == "yes"; Options.Set(OptionsKey.LiquidsBreakable, v == "yes"); }), Make(140, -50, "Pushback placing", OnWidgetClick, g => g.LocalPlayer.PushbackPlacing ? "yes" : "no", (g, v) => { g.LocalPlayer.PushbackPlacing = v == "yes"; Options.Set(OptionsKey.PushbackPlacing, v == "yes"); }), Make(140, 0, "Noclip slide", OnWidgetClick, g => g.LocalPlayer.NoclipSlide ? "yes" : "no", (g, v) => { g.LocalPlayer.NoclipSlide = v == "yes"; Options.Set(OptionsKey.NoclipSlide, v == "yes"); }), Make(140, 50, "Field of view", OnWidgetClick, g => g.FieldOfView.ToString(), (g, v) => { g.FieldOfView = Int32.Parse(v); Options.Set(OptionsKey.FieldOfView, v); g.UpdateProjection(); }), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new PauseScreen(g))), null, }; validators = new MenuInputValidator[] { new BooleanValidator(), new RealValidator(0.1f, 50), new BooleanValidator(), new RealValidator(0.1f, 1024f), new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), new IntegerValidator(1, 150), }; okayIndex = buttons.Length - 1; game.Events.HackPermissionsChanged += CheckHacksAllowed; CheckHacksAllowed(null, null); }
public override void Init() { base.Init(); INetworkProcessor network = game.Network; widgets = new Widget[] { // Column 1 MakeClassic(-165, -200, "Music", OnWidgetClick, g => g.UseMusic ? "yes" : "no", (g, v) => { g.UseMusic = v == "yes"; g.AudioPlayer.SetMusic(g.UseMusic); Options.Set(OptionsKey.UseMusic, v == "yes"); }), MakeClassic(-165, -150, "Invert mouse", OnWidgetClick, g => g.InvertMouse ? "yes" : "no", (g, v) => { g.InvertMouse = v == "yes"; Options.Set(OptionsKey.InvertMouse, v == "yes"); }), MakeClassic(-165, -100, "View distance", OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance(Int32.Parse(v), true)), !network.IsSinglePlayer ? null : MakeClassic(-165, -50, "Block physics", OnWidgetClick, g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", (g, v) => { ((SinglePlayerServer)network).physics.Enabled = v == "yes"; Options.Set(OptionsKey.SingleplayerPhysics, v == "yes"); }), // Column 2 MakeClassic(165, -200, "Sound", OnWidgetClick, g => g.UseSound ? "yes" : "no", (g, v) => { g.UseSound = v == "yes"; g.AudioPlayer.SetSound(g.UseSound); Options.Set(OptionsKey.UseSound, v == "yes"); }), MakeClassic(165, -150, "Show FPS", OnWidgetClick, g => g.ShowFPS ? "yes" : "no", (g, v) => { g.ShowFPS = v == "yes"; Options.Set(OptionsKey.ShowFPS, v == "yes"); }), MakeClassic(165, -100, "View bobbing", OnWidgetClick, g => g.ViewBobbing ? "yes" : "no", (g, v) => { g.ViewBobbing = v == "yes"; Options.Set(OptionsKey.ViewBobbing, v == "yes"); }), MakeClassic(165, -50, "FPS limit mode", OnWidgetClick, g => g.FpsLimit.ToString(), (g, v) => { object raw = Enum.Parse(typeof(FpsLimitMethod), v); g.SetFpsLimitMethod((FpsLimitMethod)raw); Options.Set(OptionsKey.FpsLimit, v); }), MakeClassic(0, 50, "Controls", LeftOnly( (g, w) => g.SetNewScreen(new ClassicKeyBindingsScreen(g))), null, null), MakeBack(false, titleFont, (g, w) => g.SetNewScreen(new PauseScreen(g))), null, null, }; widgets[7].Metadata = typeof(FpsLimitMethod); MakeValidators(); }