-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30c9479
commit 0f5a3f7
Showing
52 changed files
with
978 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"profiles": { | ||
"Client": { | ||
"commandName": "Executable", | ||
"executablePath": "dotnet", | ||
"commandLineArgs": "\"$(VINTAGE_STORY)/Vintagestory.dll\" --dataPath \"$(VINTAGE_STORY_DATA)\" --addModPath \"$(ProjectDir)/bin/mods\" \"$(VINTAGE_STORY_DATA)/Mods\"", | ||
"workingDirectory": "$(VINTAGE_STORY)" | ||
}, | ||
"Server": { | ||
"commandName": "Executable", | ||
"executablePath": "dotnet", | ||
"commandLineArgs": "\"$(VINTAGE_STORY)/VintagestoryServer.dll\" --dataPath \"$(VINTAGE_STORY_DATA)\" --addModPath \"$(ProjectDir)/bin/mods\" \"$(VINTAGE_STORY_DATA)/Mods\"", | ||
"workingDirectory": "$(VINTAGE_STORY)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,52 @@ | ||
using livemap.client.command; | ||
using System.Reflection; | ||
using HarmonyLib; | ||
using livemap.client.gui; | ||
using livemap.client.network; | ||
using livemap.client.patches; | ||
using livemap.client.util; | ||
using livemap.common; | ||
using livemap.common.configuration; | ||
using livemap.common.network; | ||
using livemap.common.util; | ||
using Vintagestory.API.Client; | ||
using Vintagestory.Common; | ||
|
||
namespace livemap.client; | ||
|
||
public sealed class LiveMapClient : LiveMapCore { | ||
public override ICoreClientAPI Api { get; } | ||
|
||
private readonly ClientHarmonyPatches _patches; | ||
private readonly Harmony _harmony; | ||
private readonly ConfigGui? _gui; | ||
|
||
protected override ClientCommandHandler CommandHandler { get; } | ||
public override ClientNetworkHandler NetworkHandler { get; } | ||
|
||
public Config? Config { get; private set; } | ||
|
||
public LiveMapClient(ICoreClientAPI api) : base(api, new ClientLoggerImpl()) { | ||
Api = api; | ||
|
||
_patches = new ClientHarmonyPatches(); | ||
_patches.Init(); | ||
_harmony = new Harmony(LiveMapMod.Id); | ||
_harmony.Patch(typeof(GameCalendar).GetProperty("YearRel", BindingFlags.Instance | BindingFlags.Public)!.GetGetMethod(), | ||
prefix: typeof(ColormapGenerator).GetMethod("PreYearRel")); | ||
|
||
if (Api.ModLoader.IsModEnabled("configlib")) { | ||
Logger.Info("Found ConfigLib. Registering gui for settings."); | ||
_gui = new ConfigGui(this); | ||
} | ||
|
||
CommandHandler = new ClientCommandHandler(this); | ||
NetworkHandler = new ClientNetworkHandler(this); | ||
} | ||
|
||
public void ReceiveConfig(ConfigPacket packet) { | ||
Logger.Debug("Received config packet from server"); | ||
Config = packet.Config!; | ||
|
||
Logger.Debug($"TileType: {Config.Web.TileType}"); | ||
} | ||
|
||
public override void Dispose() { | ||
_patches.Dispose(); | ||
_harmony.UnpatchAll(LiveMapMod.Id); | ||
|
||
_gui?.Dispose(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using ConfigLib; | ||
using livemap.client.gui.settings; | ||
using livemap.common.network; | ||
using livemap.common.util; | ||
using Vintagestory.API.Server; | ||
|
||
namespace livemap.client.gui; | ||
|
||
public class ConfigGui : Gui { | ||
private readonly LiveMapClient _client; | ||
|
||
private readonly List<Gui> _guis = new(); | ||
|
||
private bool _alreadyRequestedConfig; | ||
|
||
public ConfigGui(LiveMapClient client) { | ||
_client = client; | ||
|
||
ConfigLibModSystem? configlib = _client.Api.ModLoader.GetModSystem<ConfigLibModSystem>(); | ||
configlib.ConfigWindowClosed += OnClose; | ||
configlib.RegisterCustomConfig(LiveMapMod.Id, (_, controlButtons) => { | ||
try { | ||
return Draw(controlButtons); | ||
} catch (Exception e) { | ||
Logger.Error(e.ToString()); | ||
return new ControlButtons(false); | ||
} | ||
}); | ||
|
||
_guis.Add(new ColormapSettings(client)); | ||
_guis.Add(new HttpdSettings(client)); | ||
_guis.Add(new ZoomSettings(client)); | ||
} | ||
|
||
private ControlButtons Draw(ControlButtons controlButtons) { | ||
if (!_client.Api.World.Player.HasPrivilege(Privilege.root)) { | ||
Text($"\n{Lang.Get("access-denied.")}", true, 0xFFFF4040); | ||
return new ControlButtons(false); | ||
} | ||
|
||
if (_client.Config == null) { | ||
Text($"{Lang.Get("no-data-to-display")}", true, 0xFFFF4040); | ||
// ReSharper disable once InvertIf | ||
if (!_alreadyRequestedConfig) { | ||
_client.NetworkHandler.SendPacket(new ConfigPacket()); | ||
_alreadyRequestedConfig = true; | ||
} | ||
return new ControlButtons(false); | ||
} | ||
|
||
if (controlButtons.Save) { | ||
// saves changes to config | ||
// todo send values back to server | ||
Console.WriteLine("SAVE"); | ||
} | ||
|
||
if (controlButtons.Restore) { | ||
// retrieves values from config | ||
// todo request new values from server | ||
Console.WriteLine("RESTORE"); | ||
} | ||
|
||
if (controlButtons.Reload) { | ||
// applies settings changes | ||
// todo not needed | ||
Console.WriteLine("RELOAD"); | ||
} | ||
|
||
if (controlButtons.Defaults) { | ||
// sets settings to default values | ||
// todo do we want original defaults or current defaults? | ||
Console.WriteLine("DEFAULTS"); | ||
} | ||
|
||
Draw(); | ||
|
||
return new ControlButtons(true) { Reload = false }; | ||
} | ||
|
||
public override void Draw() { | ||
_guis.ForEach(gui => gui.Draw()); | ||
} | ||
|
||
public override void OnClose() { | ||
_guis.ForEach(gui => gui.OnClose()); | ||
} | ||
|
||
public void Dispose() { | ||
_guis.Clear(); | ||
} | ||
} |
Oops, something went wrong.