void LoadGuiOptions() { ChatLines = Options.GetInt(OptionsKey.ChatLines, 0, 30, 12); ClickableChat = Options.GetBool(OptionsKey.ClickableChat, false); InventoryScale = Options.GetFloat(OptionsKey.InventoryScale, 0.25f, 5f, 1f); HotbarScale = Options.GetFloat(OptionsKey.HotbarScale, 0.25f, 5f, 1f); ChatScale = Options.GetFloat(OptionsKey.ChatScale, 0.35f, 5f, 1f); ShowFPS = Options.GetBool(OptionsKey.ShowFPS, true); UseClassicGui = Options.GetBool(OptionsKey.ClassicGui, true) || ClassicMode; UseClassicTabList = Options.GetBool(OptionsKey.ClassicTabList, false) || ClassicMode; UseClassicOptions = Options.GetBool(OptionsKey.ClassicOptions, false) || ClassicMode; TabAutocomplete = Options.GetBool(OptionsKey.TabAutocomplete, false); FontName = Options.Get(OptionsKey.FontName, "Arial"); if (ClassicMode) { FontName = "Arial"; } try { using (Font f = new Font(FontName, 16)) { } } catch (Exception) { FontName = "Arial"; Options.Set(OptionsKey.FontName, "Arial"); } }
bool CycleZoom(MouseWheelEventArgs e) { if (!game.IsKeyDown(KeyBinding.ZoomScrolling)) { return(false); } LocalPlayer p = game.LocalPlayer; if (!p.HacksEnabled || !p.CanAnyHacks || !p.CanUseThirdPersonCamera) { return(false); } if (fovIndex == -1) { fovIndex = game.ZoomFieldOfView; } fovIndex -= e.DeltaPrecise * 5; int max = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70); Utils.Clamp(ref fovIndex, 1, max); game.FieldOfView = (int)fovIndex; game.ZoomFieldOfView = (int)fovIndex; game.UpdateProjection(); return(true); }
void UpdateHackState(bool force) { LocalPlayer p = game.LocalPlayer; if (force || p.speeding != speeding || p.halfSpeeding != halfSpeeding || p.noClip != noclip || p.flying != fly || game.ZoomFieldOfView != lastZoomFov) { speeding = p.speeding; halfSpeeding = p.halfSpeeding; noclip = p.noClip; fly = p.flying; lastZoomFov = game.ZoomFieldOfView; int index = 0; text.Clear(); int defFov = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70); if (lastZoomFov != defFov) { text.Append(ref index, "Zoom fov ") .AppendNum(ref index, lastZoomFov).Append(ref index, " "); } if (fly) { text.Append(ref index, "Fly ON "); } if (speeding || halfSpeeding) { text.Append(ref index, "Speed ON "); } if (noclip) { text.Append(ref index, "Noclip ON "); } hackStatesWidget.SetText(text.GetString()); } }
void LoadOptions() { ClassicMode = Options.GetBool("mode-classic", false); ClassicHacks = Options.GetBool(OptionsKey.AllowClassicHacks, false); AllowCustomBlocks = Options.GetBool(OptionsKey.AllowCustomBlocks, true); UseCPE = Options.GetBool(OptionsKey.UseCPE, true); SimpleArmsAnim = Options.GetBool(OptionsKey.SimpleArmsAnim, false); ViewBobbing = Options.GetBool(OptionsKey.ViewBobbing, true); FpsLimitMethod method = Options.GetEnum(OptionsKey.FpsLimit, FpsLimitMethod.LimitVSync); SetFpsLimitMethod(method); ViewDistance = Options.GetInt(OptionsKey.ViewDist, 16, 4096, 512); UserViewDistance = ViewDistance; SmoothLighting = Options.GetBool(OptionsKey.SmoothLighting, false); DefaultFov = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70); Fov = DefaultFov; ZoomFov = DefaultFov; ModifiableLiquids = !ClassicMode && Options.GetBool(OptionsKey.ModifiableLiquids, false); CameraClipping = Options.GetBool(OptionsKey.CameraClipping, true); AllowServerTextures = Options.GetBool(OptionsKey.AllowServerTextures, true); MouseSensitivity = Options.GetInt(OptionsKey.Sensitivity, 1, 100, 30); ShowBlockInHand = Options.GetBool(OptionsKey.ShowBlockInHand, true); InvertMouse = Options.GetBool(OptionsKey.InvertMouse, false); bool skipSsl = Options.GetBool("skip-ssl-check", false); if (skipSsl) { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; Options.Set("skip-ssl-check", false); } }
public void UpdateProjection() { DefaultFov = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70); Camera.GetProjection(out Graphics.Projection); Graphics.SetMatrixMode(MatrixType.Projection); Graphics.LoadMatrix(ref Graphics.Projection); Graphics.SetMatrixMode(MatrixType.Modelview); Events.RaiseProjectionChanged(); }
static void Main(string[] args) { AppDirectory = AppDomain.CurrentDomain.BaseDirectory; string logPath = Path.Combine(AppDirectory, "client.log"); ErrorHandler.InstallHandler(logPath); CleanupMainDirectory(); Configuration.SkipPerfCountersHack(); Utils.LogDebug("Starting " + AppName + ".."); string path = Path.Combine(Program.AppDirectory, "texpacks"); if (!File.Exists(Path.Combine(path, "default.zip"))) { MessageDefaultZipMissing(); return; } bool nullContext = true; #if !USE_DX nullContext = false; #endif Options.Load(); DisplayDevice device = DisplayDevice.Primary; int width = Options.GetInt(OptionsKey.WindowWidth, 0, device.Width, 0); int height = Options.GetInt(OptionsKey.WindowHeight, 0, device.Height, 0); // No custom resolution has been set if (width == 0 || height == 0) { width = 854; height = 480; if (device.Width < 854) { width = 640; } } if (args.Length == 0 || args.Length == 1) { const string skinServer = "http://static.classicube.net/skins/"; string user = args.Length > 0 ? args[0] : "Singleplayer"; using (Game game = new Game(user, null, skinServer, nullContext, width, height)) game.Run(); } else if (args.Length < 4) { Utils.LogDebug("ClassicalSharp.exe is only the raw client. You must either use the launcher or" + " provide command line arguments to start the client."); } else { RunMultiplayer(args, nullContext, width, height); } }
static void Main(string[] args) { Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; CleanupMainDirectory(); string defPath = Path.Combine("texpacks", "default.zip"); if (!Platform.FileExists(defPath)) { ErrorHandler.ShowDialog("Missing file", "default.zip not found, try running the launcher first."); return; } ErrorHandler.InstallHandler("client.log"); OpenTK.Configuration.SkipPerfCountersHack(); Utils.LogDebug("Starting " + AppName + ".."); Options.Load(); DisplayDevice device = DisplayDevice.Default; int width = Options.GetInt(OptionsKey.WindowWidth, 0, device.Bounds.Width, 0); int height = Options.GetInt(OptionsKey.WindowHeight, 0, device.Bounds.Height, 0); // No custom resolution has been set if (width == 0 || height == 0) { width = 854; height = 480; if (device.Bounds.Width < 854) { width = 640; } } if (args.Length == 0 || args.Length == 1) { const string skinServer = "http://static.classicube.net/skins/"; string user = args.Length > 0 ? args[0] : "Singleplayer"; using (Game game = new Game(user, null, skinServer, width, height)) game.Run(); } else if (args.Length < 4) { Utils.LogDebug("ClassicalSharp.exe is only the raw client. You must either use the launcher or" + " provide command line arguments to start the client."); } else { RunMultiplayer(args, width, height); } }
protected override void OnLoad(EventArgs e) { #if !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api(this); #endif Graphics.MakeGraphicsInfo(); Players = new EntityList(this); Options.Load(); AcceptedUrls.Load(); DeniedUrls.Load(); ViewDistance = Options.GetInt(OptionsKey.ViewDist, 16, 4096, 512); UserViewDistance = ViewDistance; CameraClipping = Options.GetBool(OptionsKey.CameraClipping, true); InputHandler = new InputHandler(this); Chat = new ChatLog(this); ParticleManager = new ParticleManager(this); HudScale = Options.GetFloat(OptionsKey.HudScale, 0.25f, 5f, 1f); ChatScale = Options.GetFloat(OptionsKey.ChatScale, 0.35f, 5f, 1f); defaultIb = Graphics.MakeDefaultIb(); MouseSensitivity = Options.GetInt(OptionsKey.Sensitivity, 1, 100, 30); UseClassicGui = Options.GetBool(OptionsKey.UseClassicGui, false); BlockInfo = new BlockInfo(); BlockInfo.Init(); ChatLines = Options.GetInt(OptionsKey.ChatLines, 1, 30, 12); ClickableChat = Options.GetBool(OptionsKey.ClickableChat, true); ModelCache = new ModelCache(this); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader(skinServer); Drawer2D = new GdiPlusDrawer2D(Graphics); Drawer2D.UseBitmappedChat = !Options.GetBool(OptionsKey.ArialChatFont, false); ViewBobbing = Options.GetBool(OptionsKey.ViewBobbing, false); ShowBlockInHand = Options.GetBool(OptionsKey.ShowBlockInHand, true); InvertMouse = Options.GetBool(OptionsKey.InvertMouse, false); SimpleArmsAnim = Options.GetBool(OptionsKey.SimpleArmsAnim, false); TerrainAtlas1D = new TerrainAtlas1D(Graphics); TerrainAtlas = new TerrainAtlas2D(Graphics, Drawer2D); Animations = new Animations(this); defTexturePack = Options.Get(OptionsKey.DefaultTexturePack) ?? "default.zip"; TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract("default.zip", this); // in case the user's default texture pack doesn't have all required textures if (defTexturePack != "default.zip") { extractor.Extract(DefaultTexturePack, this); } Inventory = new Inventory(this); 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); MapBordersRenderer = new MapBordersRenderer(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; FieldOfView = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70); ZoomFieldOfView = FieldOfView; UpdateProjection(); CommandManager = new CommandManager(); CommandManager.Init(this); SelectionManager = new SelectionManager(this); WeatherRenderer = new WeatherRenderer(this); WeatherRenderer.Init(); BlockHandRenderer = new BlockHandRenderer(this); BlockHandRenderer.Init(); FpsLimitMethod method = Options.GetEnum(OptionsKey.FpsLimit, FpsLimitMethod.LimitVSync); SetFpsLimitMethod(method); 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(); hudScreen = new HudScreen(this); hudScreen.Init(); Culling = new FrustumCulling(); EnvRenderer.Init(); MapBordersRenderer.Init(); Picking = new PickingRenderer(this); AudioPlayer = new AudioPlayer(this); LiquidsBreakable = Options.GetBool(OptionsKey.LiquidsBreakable, false); AxisLinesRenderer = new AxisLinesRenderer(this); LoadIcon(); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; Graphics.WarnIfNecessary(Chat); SetNewScreen(new LoadingMapScreen(this, connectString, "Waiting for handshake")); Network.Connect(IPAddress, Port); }
static void Main(string[] args) { Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; ErrorHandler.InstallHandler("client.log"); Utils.LogDebug("Starting " + AppName + ".."); Utils.EnsureDirectory("maps"); Utils.EnsureDirectory("texpacks"); Utils.EnsureDirectory("texturecache"); string defPath = Path.Combine("texpacks", "default.zip"); if (!Platform.FileExists(defPath)) { ErrorHandler.ShowDialog("Failed to start", "default.zip is missing, try running the launcher first."); return; } OpenTK.Configuration.SkipPerfCountersHack(); IPAddress ip = null; int port = 0; string user = null, mppass = null; string skinServer = "http://static.classicube.net/skins/"; if (args.Length == 0 || args.Length == 1) { user = args.Length > 0 ? args[0] : "Singleplayer"; } else if (args.Length < 4) { ErrorHandler.ShowDialog("Failed to start", "ClassicalSharp.exe is only the raw client\n\n." + "Use the launcher instead, or provide command line arguments"); return; } else { user = args[0]; mppass = args[1]; if (args.Length > 4) { skinServer = args[4]; } if (!IPAddress.TryParse(args[2], out ip)) { ErrorHandler.ShowDialog("Failed to start", "Invalid IP " + args[2]); return; } if (!Int32.TryParse(args[3], out port) || port <0 || port> ushort.MaxValue) { ErrorHandler.ShowDialog("Failed to start", "Invalid port " + args[3]); return; } } Options.Load(); DisplayDevice device = DisplayDevice.Default; int width = Options.GetInt(OptionsKey.WindowWidth, 0, device.Bounds.Width, 0); int height = Options.GetInt(OptionsKey.WindowHeight, 0, device.Bounds.Height, 0); // No custom resolution has been set if (width == 0 || height == 0) { width = 854; height = 480; if (device.Bounds.Width < 854) { width = 640; } } using (Game game = new Game(user, mppass, skinServer, width, height)) { game.IPAddress = ip; game.Port = port; game.Run(); } }