mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
Make the launcher compile with C# 2.0 compiler
This commit is contained in:
parent
3c6bf3624c
commit
113d3e3b5b
@ -64,8 +64,9 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public override void DisposeInstance() {
|
||||
foreach (var pair in brushCache)
|
||||
foreach (KeyValuePair<int, SolidBrush> pair in brushCache) {
|
||||
pair.Value.Dispose();
|
||||
}
|
||||
|
||||
DisposeText();
|
||||
DisposeBitmappedText();
|
||||
|
@ -30,7 +30,6 @@ namespace ClassicalSharp.Textures {
|
||||
if (game.Graphics.LostContext) return;
|
||||
|
||||
ZipReader reader = new ZipReader();
|
||||
reader.ShouldProcessZipEntry = (f) => true;
|
||||
reader.ProcessZipEntry = ProcessZipEntry;
|
||||
reader.Extract(stream);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace ClassicalSharp.Textures {
|
||||
public sealed class ZipReader {
|
||||
|
||||
public ZipEntryProcessor ProcessZipEntry;
|
||||
public ZipEntrySelector ShouldProcessZipEntry;
|
||||
public ZipEntrySelector SelectZipEntry;
|
||||
public ZipEntry[] entries;
|
||||
int index;
|
||||
|
||||
@ -81,10 +81,11 @@ namespace ClassicalSharp.Textures {
|
||||
if (compressedSize == 0) compressedSize = entry.CompressedDataSize;
|
||||
int uncompressedSize = reader.ReadInt32();
|
||||
if (uncompressedSize == 0) uncompressedSize = entry.UncompressedDataSize;
|
||||
|
||||
ushort fileNameLen = reader.ReadUInt16();
|
||||
ushort extraFieldLen = reader.ReadUInt16();
|
||||
string fileName = enc.GetString(reader.ReadBytes(fileNameLen));
|
||||
if (!ShouldProcessZipEntry(fileName)) return;
|
||||
if (SelectZipEntry != null && !SelectZipEntry(fileName)) return;
|
||||
|
||||
reader.ReadBytes(extraFieldLen);
|
||||
if (versionNeeded > 20)
|
||||
|
@ -19,17 +19,20 @@ namespace Launcher.Gui.Screens {
|
||||
base.Init();
|
||||
view.Init();
|
||||
|
||||
widgets[view.nIndex].OnClick = (x, y) => ModeClick(false, false);
|
||||
widgets[view.clIndex].OnClick = (x, y) => ModeClick(true, false);
|
||||
widgets[view.clHaxIndex].OnClick = (x, y) => ModeClick(true, true);
|
||||
|
||||
widgets[view.nIndex].OnClick = UseModeEnhanced;
|
||||
widgets[view.clIndex].OnClick = UseModeClassicHax;
|
||||
widgets[view.clHaxIndex].OnClick = UseModeClassic;
|
||||
if (view.backIndex >= 0) {
|
||||
widgets[view.backIndex].OnClick = (x, y)
|
||||
=> game.SetScreen(new SettingsScreen(game));
|
||||
widgets[view.backIndex].OnClick = SwitchToSettings;
|
||||
}
|
||||
Resize();
|
||||
}
|
||||
|
||||
void UseModeEnhanced(int x, int y) { ModeClick(false, false); }
|
||||
void UseModeClassicHax(int x, int y) { ModeClick(true, false); }
|
||||
void UseModeClassic(int x, int y) { ModeClick(true, true); }
|
||||
void SwitchToSettings(int x, int y) { game.SetScreen(new SettingsScreen(game)); }
|
||||
|
||||
public override void Tick() { }
|
||||
|
||||
public override void Resize() {
|
||||
|
@ -20,8 +20,8 @@ namespace Launcher.Gui.Screens {
|
||||
base.Init();
|
||||
view.Init();
|
||||
|
||||
widgets[view.defIndex].OnClick = (x, y) => ResetColours();
|
||||
widgets[view.defIndex + 1].OnClick = (x, y) => game.SetScreen(new SettingsScreen(game));
|
||||
widgets[view.defIndex].OnClick = ResetColours;
|
||||
widgets[view.defIndex + 1].OnClick = SwitchToSettings;
|
||||
SetupInputHandlers();
|
||||
for (int i = 0; i < widgets.Length; i++) {
|
||||
InputWidget input = widgets[i] as InputWidget;
|
||||
@ -31,6 +31,14 @@ namespace Launcher.Gui.Screens {
|
||||
Resize();
|
||||
}
|
||||
|
||||
void SwitchToSettings(int x, int y) { game.SetScreen(new SettingsScreen(game)); }
|
||||
void ResetColours(int x, int y) {
|
||||
LauncherSkin.ResetToDefault();
|
||||
view.MakeAllRGBTriplets(true);
|
||||
game.RedrawBackground();
|
||||
Resize();
|
||||
}
|
||||
|
||||
public override void Resize() {
|
||||
view.DrawAll();
|
||||
game.Dirty = true;
|
||||
@ -50,7 +58,7 @@ namespace Launcher.Gui.Screens {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
SliderWidget slider = (SliderWidget)widgets[view.sliderIndex + i];
|
||||
if (x < slider.X || y < slider.Y || x >= slider.X + slider.Width
|
||||
|| y >= slider.Y + slider.Height) continue;
|
||||
|| y >= slider.Y + slider.Height) continue;
|
||||
|
||||
int value = x - slider.X;
|
||||
// Map from 0 to 255
|
||||
@ -97,13 +105,6 @@ namespace Launcher.Gui.Screens {
|
||||
TextChanged(curInput);
|
||||
}
|
||||
|
||||
void ResetColours() {
|
||||
LauncherSkin.ResetToDefault();
|
||||
view.MakeAllRGBTriplets(true);
|
||||
game.RedrawBackground();
|
||||
Resize();
|
||||
}
|
||||
|
||||
void TextChanged(InputWidget widget) {
|
||||
bool changed = false;
|
||||
int index = Array.IndexOf<Widget>(widgets, widget);
|
||||
@ -121,8 +122,8 @@ namespace Launcher.Gui.Screens {
|
||||
bool Parse(int index, ref FastColour dst) {
|
||||
byte r, g, b;
|
||||
if (!Byte.TryParse(widgets[index + 0].Text, out r)
|
||||
|| !Byte.TryParse(widgets[index + 1].Text, out g)
|
||||
|| !Byte.TryParse(widgets[index + 2].Text, out b))
|
||||
|| !Byte.TryParse(widgets[index + 1].Text, out g)
|
||||
|| !Byte.TryParse(widgets[index + 2].Text, out b))
|
||||
return false;
|
||||
dst.R = r; dst.G = g; dst.B = b;
|
||||
return true;
|
||||
|
@ -32,14 +32,15 @@ namespace Launcher.Gui.Screens {
|
||||
}
|
||||
|
||||
void SetWidgetHandlers() {
|
||||
widgets[view.backIndex].OnClick =
|
||||
(x, y) => game.SetScreen(new MainScreen(game));
|
||||
widgets[view.backIndex].OnClick = SwitchToMain;
|
||||
widgets[view.connectIndex].OnClick = StartClient;
|
||||
widgets[view.ccSkinsIndex].OnClick = UseClassicubeSkinsClick;
|
||||
SetupInputHandlers();
|
||||
LoadSavedInfo();
|
||||
}
|
||||
|
||||
void SwitchToMain(int x, int y) { game.SetScreen(new MainScreen(game)); }
|
||||
|
||||
void SetStatus(string text) {
|
||||
LabelWidget widget = (LabelWidget)widgets[view.statusIndex];
|
||||
game.ResetArea(widget.X, widget.Y, widget.Width, widget.Height);
|
||||
|
@ -22,7 +22,13 @@ namespace Launcher.Gui.Screens {
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
view.Init();
|
||||
SetupWidgetHandlers();
|
||||
|
||||
widgets[view.loginIndex].OnClick = LoginAsync;
|
||||
widgets[view.resIndex].OnClick = DoResume;
|
||||
widgets[view.dcIndex].OnClick = SwitchToDirectConnect;
|
||||
widgets[view.spIndex].OnClick = StartSingleplayer;
|
||||
widgets[view.settingsIndex].OnClick = SwitchToSettings;
|
||||
SetupInputHandlers();
|
||||
Resize();
|
||||
|
||||
using (drawer) {
|
||||
@ -36,6 +42,38 @@ namespace Launcher.Gui.Screens {
|
||||
game.Dirty = true;
|
||||
}
|
||||
|
||||
void SwitchToDirectConnect(int x, int y) { game.SetScreen(new DirectConnectScreen(game)); }
|
||||
void StartSingleplayer(int x, int y) { Client.Start(widgets[0].Text, ref game.ShouldExit); }
|
||||
void SwitchToSettings(int x, int y) { game.SetScreen(new SettingsScreen(game)); }
|
||||
|
||||
const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;
|
||||
string resumeUser, resumeIp, resumePort, resumeMppass;
|
||||
bool resumeCCSkins, resumeValid;
|
||||
|
||||
void DoResume(int mouseX, int mouseY) {
|
||||
if (!resumeValid) return;
|
||||
ClientStartData data = new ClientStartData(resumeUser, resumeMppass, resumeIp, resumePort);
|
||||
Client.Start(data, resumeCCSkins, ref game.ShouldExit);
|
||||
}
|
||||
|
||||
|
||||
void LoadResumeInfo() {
|
||||
resumeUser = Options.Get("launcher-username");
|
||||
resumeIp = Options.Get("launcher-ip") ?? "";
|
||||
resumePort = Options.Get("launcher-port") ?? "";
|
||||
resumeCCSkins = Options.GetBool("launcher-ccskins", true);
|
||||
|
||||
IPAddress address;
|
||||
if (!IPAddress.TryParse(resumeIp, out address)) resumeIp = "";
|
||||
ushort portNum;
|
||||
if (!UInt16.TryParse(resumePort, out portNum)) resumePort = "";
|
||||
|
||||
string mppass = Options.Get("launcher-mppass") ?? null;
|
||||
resumeMppass = Secure.Decode(mppass, resumeUser);
|
||||
resumeValid = !String.IsNullOrEmpty(resumeUser) && !String.IsNullOrEmpty(resumeIp)
|
||||
&& !String.IsNullOrEmpty(resumePort) && !String.IsNullOrEmpty(resumeMppass);
|
||||
}
|
||||
|
||||
bool updateDone;
|
||||
void SuccessfulUpdateCheck(UpdateCheckTask task) {
|
||||
string latestVer = game.checkTask.LatestStable.Version.Substring(1);
|
||||
@ -56,45 +94,6 @@ namespace Launcher.Gui.Screens {
|
||||
SelectWidget(selectedWidget, 0, 0);
|
||||
}
|
||||
|
||||
void SetupWidgetHandlers() {
|
||||
widgets[view.loginIndex].OnClick = LoginAsync;
|
||||
widgets[view.resIndex].OnClick = ResumeClick;
|
||||
widgets[view.dcIndex].OnClick =
|
||||
(x, y) => game.SetScreen(new DirectConnectScreen(game));
|
||||
widgets[view.spIndex].OnClick =
|
||||
(x, y) => Client.Start(widgets[0].Text, ref game.ShouldExit);
|
||||
|
||||
widgets[view.settingsIndex].OnClick =
|
||||
(x, y) => game.SetScreen(new SettingsScreen(game));
|
||||
SetupInputHandlers();
|
||||
}
|
||||
|
||||
const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;
|
||||
string resumeUser, resumeIp, resumePort, resumeMppass;
|
||||
bool resumeCCSkins, resumeValid;
|
||||
|
||||
void LoadResumeInfo() {
|
||||
resumeUser = Options.Get("launcher-username");
|
||||
resumeIp = Options.Get("launcher-ip") ?? "";
|
||||
resumePort = Options.Get("launcher-port") ?? "";
|
||||
resumeCCSkins = Options.GetBool("launcher-ccskins", true);
|
||||
|
||||
IPAddress address;
|
||||
if (!IPAddress.TryParse(resumeIp, out address)) resumeIp = "";
|
||||
ushort portNum;
|
||||
if (!UInt16.TryParse(resumePort, out portNum)) resumePort = "";
|
||||
|
||||
string mppass = Options.Get("launcher-mppass") ?? null;
|
||||
resumeMppass = Secure.Decode(mppass, resumeUser);
|
||||
resumeValid = !String.IsNullOrEmpty(resumeUser) && !String.IsNullOrEmpty(resumeIp)
|
||||
&& !String.IsNullOrEmpty(resumePort) && !String.IsNullOrEmpty(resumeMppass);
|
||||
}
|
||||
|
||||
void ResumeClick(int mouseX, int mouseY) {
|
||||
if (!resumeValid) return;
|
||||
ClientStartData data = new ClientStartData(resumeUser, resumeMppass, resumeIp, resumePort);
|
||||
Client.Start(data, resumeCCSkins, ref game.ShouldExit);
|
||||
}
|
||||
|
||||
protected override void SelectWidget(Widget widget, int mouseX, int mouseY) {
|
||||
base.SelectWidget(widget, mouseX, mouseY);
|
||||
|
@ -27,8 +27,8 @@ namespace Launcher.Gui.Screens {
|
||||
|
||||
void SetWidgetHandlers() {
|
||||
widgets[view.yesIndex].OnClick = DownloadResources;
|
||||
widgets[view.noIndex].OnClick = (x, y) => GotoNextMenu();
|
||||
widgets[view.cancelIndex].OnClick = (x, y) => GotoNextMenu();
|
||||
widgets[view.noIndex].OnClick = GotoNextMenu;
|
||||
widgets[view.cancelIndex].OnClick = GotoNextMenu;
|
||||
}
|
||||
|
||||
bool failed;
|
||||
@ -48,7 +48,7 @@ namespace Launcher.Gui.Screens {
|
||||
fetcher = null;
|
||||
GC.Collect();
|
||||
game.TryLoadTexturePack();
|
||||
GotoNextMenu();
|
||||
GotoNextMenu(0, 0);
|
||||
}
|
||||
|
||||
public override void Resize() {
|
||||
@ -92,7 +92,7 @@ namespace Launcher.Gui.Screens {
|
||||
Resize();
|
||||
}
|
||||
|
||||
void GotoNextMenu() {
|
||||
void GotoNextMenu(int x, int y) {
|
||||
if (File.Exists("options.txt")) {
|
||||
game.SetScreen(new MainScreen(game));
|
||||
} else {
|
||||
|
@ -101,8 +101,7 @@ namespace Launcher.Gui.Screens {
|
||||
InputWidget hashWidget = (InputWidget)widgets[view.hashIndex];
|
||||
hashWidget.Chars.ClipboardFilter = HashFilter;
|
||||
|
||||
widgets[view.backIndex].OnClick =
|
||||
(x, y) => game.SetScreen(new MainScreen(game));
|
||||
widgets[view.backIndex].OnClick = SwitchToMain;
|
||||
widgets[view.connectIndex].OnClick = ConnectToServer;
|
||||
widgets[view.refreshIndex].OnClick = RefreshList;
|
||||
|
||||
@ -112,6 +111,8 @@ namespace Launcher.Gui.Screens {
|
||||
SetupInputHandlers();
|
||||
}
|
||||
|
||||
void SwitchToMain(int x, int y) { game.SetScreen(new MainScreen(game)); }
|
||||
|
||||
void FilterList() {
|
||||
if (curInput != widgets[view.searchIndex])
|
||||
return;
|
||||
|
@ -18,17 +18,18 @@ namespace Launcher.Gui.Screens {
|
||||
base.Init();
|
||||
view.Init();
|
||||
|
||||
widgets[view.modeIndex].OnClick = (x, y) =>
|
||||
game.SetScreen(new ChooseModeScreen(game, false));
|
||||
widgets[view.updatesIndex].OnClick = (x, y) =>
|
||||
game.SetScreen(new UpdatesScreen(game));
|
||||
widgets[view.coloursIndex].OnClick = (x, y) =>
|
||||
game.SetScreen(new ColoursScreen(game));
|
||||
widgets[view.backIndex].OnClick = (x, y) =>
|
||||
game.SetScreen(new MainScreen(game));
|
||||
widgets[view.modeIndex].OnClick = SwitchToChooseMode;
|
||||
widgets[view.updatesIndex].OnClick = SwitchToUpdates;
|
||||
widgets[view.coloursIndex].OnClick = SwitchToColours;
|
||||
widgets[view.backIndex].OnClick = SwitchToMain;
|
||||
Resize();
|
||||
}
|
||||
|
||||
void SwitchToChooseMode(int x, int y) { game.SetScreen(new ChooseModeScreen(game, false)); }
|
||||
void SwitchToUpdates(int x, int y) { game.SetScreen(new UpdatesScreen(game)); }
|
||||
void SwitchToColours(int x, int y) { game.SetScreen(new ColoursScreen(game)); }
|
||||
void SwitchToMain(int x, int y) { game.SetScreen(new MainScreen(game)); }
|
||||
|
||||
public override void Tick() { }
|
||||
|
||||
public override void Resize() {
|
||||
|
@ -22,12 +22,17 @@ namespace Launcher.Gui.Screens {
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
view.Init();
|
||||
SetWidgetHandlers();
|
||||
|
||||
widgets[view.relIndex].OnClick = UpdateStableD3D9;
|
||||
widgets[view.relIndex + 1].OnClick = UpdateStableOpenGL;
|
||||
widgets[view.devIndex].OnClick = UpdateDevD3D9;
|
||||
widgets[view.devIndex + 1].OnClick = UpdateStableOpenGL;
|
||||
widgets[view.backIndex].OnClick = SwitchToSettings;
|
||||
Resize();
|
||||
|
||||
if (game.checkTask != null && game.checkTask.Done && game.checkTask.Success)
|
||||
if (game.checkTask != null && game.checkTask.Done && game.checkTask.Success) {
|
||||
SuccessfulUpdateCheck(game.checkTask);
|
||||
|
||||
}
|
||||
checkTask = new UpdateCheckTask();
|
||||
checkTask.CheckForUpdatesAsync();
|
||||
}
|
||||
@ -67,16 +72,11 @@ namespace Launcher.Gui.Screens {
|
||||
game.Dirty = true;
|
||||
}
|
||||
|
||||
void SetWidgetHandlers() {
|
||||
widgets[view.relIndex].OnClick = (x, y) => UpdateBuild(true, true);
|
||||
widgets[view.relIndex + 1].OnClick = (x, y) => UpdateBuild(true, false);
|
||||
|
||||
widgets[view.devIndex].OnClick = (x, y) => UpdateBuild(false, true);
|
||||
widgets[view.devIndex + 1].OnClick = (x, y) => UpdateBuild(false, false);
|
||||
|
||||
widgets[view.backIndex].OnClick =
|
||||
(x, y) => game.SetScreen(new SettingsScreen(game));
|
||||
}
|
||||
void UpdateStableD3D9(int x, int y) { UpdateBuild(true, true); }
|
||||
void UpdateStableOpenGL(int x, int y) { UpdateBuild(true, false); }
|
||||
void UpdateDevD3D9(int x, int y) { UpdateBuild(false, true); }
|
||||
void UpdateDevOpenGL(int x, int y) { UpdateBuild(false, false); }
|
||||
void SwitchToSettings(int x, int y) { game.SetScreen(new MainScreen(game)); }
|
||||
|
||||
void UpdateBuild(bool release, bool dx) {
|
||||
DateTime last = release ? view.LastStable : view.LastDev;
|
||||
|
@ -60,14 +60,10 @@ namespace Launcher.Gui.Widgets {
|
||||
public void RedrawData(IDrawer2D drawer) {
|
||||
int x = table.X + 5;
|
||||
DrawGrid(drawer);
|
||||
x += DrawColumn(drawer, false, font, titleFont,
|
||||
"Name", table.ColumnWidths[0], x, e => e.Name) + 5;
|
||||
x += DrawColumn(drawer, true, font, titleFont,
|
||||
"Players", table.ColumnWidths[1], x, e => e.Players) + 5;
|
||||
x += DrawColumn(drawer, true, font, titleFont,
|
||||
"Uptime", table.ColumnWidths[2], x, e => e.Uptime) + 5;
|
||||
x += DrawColumn(drawer, true, font, titleFont,
|
||||
"Software", table.ColumnWidths[3], x, e => e.Software) + 5;
|
||||
x += DrawColumn(drawer, "Name", 0, x, filterName) + 5;
|
||||
x += DrawColumn(drawer, "Players", 1, x, filterPlayers) + 5;
|
||||
x += DrawColumn(drawer, "Uptime", 2, x, filterUptime) + 5;
|
||||
x += DrawColumn(drawer, "Software", 3, x, FilterSoftware) + 5;
|
||||
DrawScrollbar(drawer);
|
||||
}
|
||||
|
||||
@ -77,16 +73,23 @@ namespace Launcher.Gui.Widgets {
|
||||
}
|
||||
|
||||
delegate string ColumnFilter(TableEntry entry);
|
||||
// cache to avoid allocations every redraw
|
||||
static string FilterName(TableEntry e) { return e.Name; } static ColumnFilter filterName = FilterName;
|
||||
static string FilterPlayers(TableEntry e) { return e.Players; } static ColumnFilter filterPlayers = FilterPlayers;
|
||||
static string FilterUptime(TableEntry e) { return e.Uptime; } static ColumnFilter filterUptime = FilterUptime;
|
||||
static string FilterSoftware(TableEntry e) { return e.Software; } static ColumnFilter filterSoftware = FilterSoftware;
|
||||
|
||||
int DrawColumn(IDrawer2D drawer, bool separator, Font font, Font titleFont,
|
||||
string header, int maxWidth, int x, ColumnFilter filter) {
|
||||
int DrawColumn(IDrawer2D drawer, string header, int columnI, int x, ColumnFilter filter) {
|
||||
int y = table.Y + 3;
|
||||
int maxWidth = table.ColumnWidths[columnI];
|
||||
bool separator = columnI > 0;
|
||||
|
||||
DrawTextArgs args = new DrawTextArgs(header, titleFont, true);
|
||||
TableEntry headerEntry = default(TableEntry);
|
||||
DrawColumnEntry(drawer, ref args, maxWidth, x, ref y, ref headerEntry);
|
||||
maxIndex = table.Count;
|
||||
y += 5;
|
||||
|
||||
y += 5;
|
||||
for (int i = table.CurrentIndex; i < table.Count; i++) {
|
||||
args = new DrawTextArgs(filter(table.usedEntries[i]), font, true);
|
||||
if (i == table.SelectedIndex && !separator) {
|
||||
@ -100,8 +103,9 @@ namespace Launcher.Gui.Widgets {
|
||||
}
|
||||
}
|
||||
|
||||
if (separator && !window.ClassicBackground)
|
||||
if (separator && !window.ClassicBackground) {
|
||||
drawer.Clear(LauncherSkin.BackgroundCol, x - 7, table.Y, 2, table.Height);
|
||||
}
|
||||
return maxWidth + 5;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<Project ToolsVersion="2.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -40,12 +40,16 @@ namespace Launcher {
|
||||
void ExtractTexturePack(string texPack) {
|
||||
using (Stream fs = new FileStream(texPack, FileMode.Open, FileAccess.Read, FileShare.Read)) {
|
||||
ZipReader reader = new ZipReader();
|
||||
reader.ShouldProcessZipEntry = (f) => f == "default.png" || f == "terrain.png";
|
||||
reader.SelectZipEntry = SelectZipEntry;
|
||||
reader.ProcessZipEntry = ProcessZipEntry;
|
||||
reader.Extract(fs);
|
||||
}
|
||||
}
|
||||
|
||||
bool SelectZipEntry(string filename) {
|
||||
return filename == "default.png" || filename == "terrain.png";
|
||||
}
|
||||
|
||||
void ProcessZipEntry(string filename, byte[] data, ZipEntry entry) {
|
||||
if (filename == "default.png") {
|
||||
if (fontPng) return;
|
||||
|
@ -75,14 +75,14 @@ namespace Launcher.Patcher {
|
||||
|
||||
void CheckDefaultZip(string path) {
|
||||
ZipReader reader = new ZipReader();
|
||||
reader.ShouldProcessZipEntry = ShouldProcessZipEntry;
|
||||
reader.SelectZipEntry = SelectZipEntry;
|
||||
reader.ProcessZipEntry = ProcessZipEntry;
|
||||
|
||||
using (Stream src = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
reader.Extract(src);
|
||||
}
|
||||
|
||||
bool ShouldProcessZipEntry(string filename) {
|
||||
bool SelectZipEntry(string filename) {
|
||||
string name = ResourceList.GetFile(filename);
|
||||
for (int i = 0; i < ResourceList.Filenames.Length; i++) {
|
||||
if (ResourceList.FilesExist[i]) continue;
|
||||
|
@ -28,7 +28,7 @@ namespace Launcher.Patcher {
|
||||
byte[] jarClassic, jar162, pngTerrainPatch, pngGuiPatch;
|
||||
public void Run() {
|
||||
reader = new ZipReader();
|
||||
reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Classic;
|
||||
reader.SelectZipEntry = SelectZipEntry_Classic;
|
||||
reader.ProcessZipEntry = ProcessZipEntry_Classic;
|
||||
string texDir = Path.Combine(Program.AppDirectory, "texpacks");
|
||||
string path = Path.Combine(texDir, "default.zip");
|
||||
@ -59,7 +59,6 @@ namespace Launcher.Patcher {
|
||||
if (!File.Exists(path)) return;
|
||||
|
||||
using (Stream src = new FileStream(path, FileMode.Open, FileAccess.Read)) {
|
||||
reader.ShouldProcessZipEntry = (file) => true;
|
||||
reader.ProcessZipEntry = ExtractExisting;
|
||||
reader.Extract(src);
|
||||
}
|
||||
@ -80,13 +79,13 @@ namespace Launcher.Patcher {
|
||||
void ExtractClassic() {
|
||||
if (jarClassic == null) return;
|
||||
using (Stream src = new MemoryStream(jarClassic)) {
|
||||
reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Classic;
|
||||
reader.SelectZipEntry = SelectZipEntry_Classic;
|
||||
reader.ProcessZipEntry = ProcessZipEntry_Classic;
|
||||
reader.Extract(src);
|
||||
}
|
||||
}
|
||||
|
||||
bool ShouldProcessZipEntry_Classic(string filename) {
|
||||
bool SelectZipEntry_Classic(string filename) {
|
||||
return filename.StartsWith("gui")
|
||||
|| filename.StartsWith("mob") || filename.IndexOf('/') < 0;
|
||||
}
|
||||
@ -121,7 +120,7 @@ namespace Launcher.Patcher {
|
||||
using (Stream src = new MemoryStream(jar162)) {
|
||||
// Grab animations and snow
|
||||
animBitmap = Platform.CreateBmp(1024, 64);
|
||||
reader.ShouldProcessZipEntry = ShouldProcessZipEntry_Modern;
|
||||
reader.SelectZipEntry = SelectZipEntry_Modern;
|
||||
reader.ProcessZipEntry = ProcessZipEntry_Modern;
|
||||
reader.Extract(src);
|
||||
|
||||
@ -133,7 +132,7 @@ namespace Launcher.Patcher {
|
||||
}
|
||||
}
|
||||
|
||||
bool ShouldProcessZipEntry_Modern(string filename) {
|
||||
bool SelectZipEntry_Modern(string filename) {
|
||||
return filename.StartsWith("assets/minecraft/textures") &&
|
||||
(filename == "assets/minecraft/textures/environment/snow.png" ||
|
||||
filename == "assets/minecraft/textures/blocks/water_still.png" ||
|
||||
|
@ -60,7 +60,6 @@ namespace Launcher.Updater {
|
||||
string path = Path.Combine(Program.AppDirectory, "CS_Update");
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
reader.ShouldProcessZipEntry = (f) => true;
|
||||
reader.ProcessZipEntry = ProcessZipEntry;
|
||||
reader.Extract(stream);
|
||||
}
|
||||
|
@ -54,14 +54,15 @@ namespace Launcher.Web {
|
||||
JsonObject devBuild = (JsonObject)data["latest"];
|
||||
JsonObject releaseBuilds = (JsonObject)data["releases"];
|
||||
LatestDev = MakeBuild(devBuild, false);
|
||||
Build[] stableBuilds = new Build[releaseBuilds.Count];
|
||||
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, object> pair in releaseBuilds)
|
||||
stableBuilds[i++] = MakeBuild((JsonObject)pair.Value, true);
|
||||
Array.Sort<Build>(stableBuilds,
|
||||
(a, b) => b.TimeBuilt.CompareTo(a.TimeBuilt));
|
||||
LatestStable = stableBuilds[0];
|
||||
DateTime releaseTime = DateTime.MinValue;
|
||||
foreach (KeyValuePair<string, object> pair in releaseBuilds) {
|
||||
Build build = MakeBuild((JsonObject)pair.Value, true);
|
||||
if (build.TimeBuilt < releaseTime) continue;
|
||||
|
||||
LatestStable = build;
|
||||
releaseTime = build.TimeBuilt;
|
||||
}
|
||||
}
|
||||
|
||||
static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user