Skip to content

Commit b21a72b

Browse files
committed
fixed and adjustments
1 parent 6e5e775 commit b21a72b

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

ModLoader/JSBridge.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,13 @@ public string GenerateGid(string publicKey)
161161
{
162162
if (!Form1.HandleArgs(publicKey)) return "";
163163

164-
string encoded = Form1.cryptoHelper.EncodeToBase64(publicKey);
165-
if (encoded.Length >= 20)
164+
if (publicKey.Length >= 120)
166165
{
167-
return encoded.Substring(0, 20);
166+
return Form1.cryptoHelper.EncodeToBase64(publicKey.Substring(80, 40));
168167
}
169168
else
170169
{
171-
return encoded.Substring(0, encoded.Length);
170+
return Form1.cryptoHelper.EncodeToBase64(publicKey.Substring(0, publicKey.Length));
172171
}
173172
}
174173

@@ -180,6 +179,11 @@ public void NavigateToUrl(string url)
180179
//Form1.webView.CoreWebView2.AddHostObjectToScript("dcts", Form1.bridge);
181180
}
182181

182+
public void NavigateHome()
183+
{
184+
Form1.formhelper.NavigateHome();
185+
}
186+
183187
private async Task WaitUntilDone()
184188
{
185189
installDoneTcs = new TaskCompletionSource<bool>();
@@ -207,6 +211,12 @@ public string GetServers()
207211
return JsonSerializer.Serialize(Form1.storage.GetServers());
208212
}
209213

214+
public string GetServer(string address)
215+
{
216+
if (!Form1.HandleArgs(address)) return "";
217+
return JsonSerializer.Serialize(Form1.storage.GetServer(address));
218+
}
219+
210220
public void DeleteServer(string address)
211221
{
212222
if (!Form1.HandleArgs(address)) return;

ModLoader/StorageHelper.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ public class AppSettings
2626
public string UriScheme { get; set; } = "dcts";
2727
public string SkippedVersion { get; set; } = "";
2828
}
29+
public class ServerInfo
30+
{
31+
public string Address { get; set; }
32+
public string JsonData { get; set; }
33+
public bool IsFavourite { get; set; }
34+
}
35+
36+
37+
38+
39+
2940

3041
public static AppSettings Current { get; private set; } = new AppSettings();
3142

@@ -94,13 +105,6 @@ public static void SetSetting(string settingName, string value)
94105
}
95106
}
96107

97-
public class ServerInfo
98-
{
99-
public string Address { get; set; }
100-
public string JsonData { get; set; }
101-
public bool IsFavourite { get; set; }
102-
}
103-
104108

105109
public Dictionary<string, ServerInfo> GetServers()
106110
{
@@ -157,6 +161,15 @@ public bool SaveServer(string address, string jsonData, bool isFav = false)
157161
}
158162
}
159163

164+
public ServerInfo GetServer(string address)
165+
{
166+
Dictionary<string, ServerInfo> SavedServers = GetServers();
167+
if (SavedServers.ContainsKey(address)){
168+
return SavedServers[address];
169+
}
170+
return null;
171+
}
172+
160173
public void DeleteServer(string address)
161174
{
162175
Dictionary<string, ServerInfo> SavedServers = GetServers();

ModLoader/web/script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ async function getSavedServers(container){
7777

7878
let serverData = await Client().GetServers();
7979
let servers = JSON.parse(serverData)
80-
8180
renderServersList(servers)
8281
}
8382

@@ -90,6 +89,7 @@ async function renderServersList(servers) {
9089
for(let server in servers){
9190
let serverObj = servers[server];
9291
let address = serverObj.Address;
92+
console.log(serverObj.JsonData)
9393
let serverData = JSON.parse(serverObj.JsonData);
9494

9595
if (!serverData || serverData.length <= 0) {
@@ -123,7 +123,7 @@ async function renderServersList(servers) {
123123
</div>
124124
125125
<div class="footer">
126-
${encodePlainText(serverData.serverinfo.slots.online)} / ${encodePlainText(serverData.serverinfo.slots.limit)} Online • ${encodePlainText(serverData.serverinfo.slots.reserved)} reserved
126+
${serverData.serverinfo.slots.online ? encodePlainText(serverData.serverinfo.slots.online) : "0"} / ${encodePlainText(serverData.serverinfo.slots.limit)} Online • ${encodePlainText(serverData.serverinfo.slots.reserved)} reserved
127127
<a class="joinButton" href="http://${address}">Join</a>
128128
</div>
129129
`;

ModLoader/web/style.css

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* cyan: #012724;*/
66
/* purple: #1d1635;*/
77
--main: #131415;
8-
--card-radius: 20px;
8+
--card-radius: 10px;
99
--accent: #131415;
1010
}
1111

@@ -85,7 +85,7 @@ table td, table th {
8585
.server-card {
8686
background: linear-gradient(130deg, hsl(from var(--accent) h s calc(l * 3)), hsl(from var(--accent) h s calc(l * 3.5)));
8787
color: hsl(from var(--accent) h s calc(l * 10));
88-
width: 350px;
88+
width: 250px;
8989
height: fit-content;
9090
float: left;
9191

@@ -147,9 +147,19 @@ table td, table th {
147147
font-size: 14px;
148148
text-align: left;
149149

150-
max-height: 200px !important;
151-
text-overflow: ellipsis;
152150
overflow: hidden;
151+
max-height: 50px;
152+
transition: all 500ms;
153+
user-select: none;
154+
}
155+
156+
.server-card .about:hover{
157+
max-height: 200px;
158+
overflow: auto;
159+
}
160+
161+
.server-card .about p{
162+
margin-top: 0;
153163
}
154164

155165
.server-card .about a, table a {
@@ -166,7 +176,6 @@ table td, table th {
166176
justify-content: center;
167177
gap: 6px;
168178

169-
170179
border-top: 1px solid hsl(from var(--accent) h s calc(l * 1));
171180
border-bottom: 1px solid hsl(from var(--accent) h s calc(l * 1));
172181
}
@@ -190,6 +199,7 @@ table td, table th {
190199
font-weight: bold;
191200

192201
cursor: pointer;
202+
user-select: none;
193203
}
194204

195205
.footer {
@@ -213,6 +223,7 @@ table td, table th {
213223

214224
display: flex;
215225
margin-left: auto;
226+
user-select: none;
216227
}
217228

218229

0 commit comments

Comments
 (0)