Skip to content

Commit 432c81e

Browse files
committed
Developer mode, dedicated secrets config file and Lambda API config
1 parent af2c803 commit 432c81e

File tree

14 files changed

+110
-51
lines changed

14 files changed

+110
-51
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.config.configurations
19+
20+
import com.lambda.config.Configuration
21+
import com.lambda.util.FolderRegister
22+
import java.io.File
23+
24+
object SecretsConfig : Configuration() {
25+
override val configName get() = "secrets"
26+
override val primary: File = FolderRegister.config.resolve("$configName.json").toFile()
27+
}

src/main/kotlin/com/lambda/gui/MenuBar.kt

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import com.lambda.gui.components.SettingsWidget.buildConfigSettingsContext
3333
import com.lambda.gui.dsl.ImGuiBuilder
3434
import com.lambda.module.ModuleRegistry
3535
import com.lambda.module.tag.ModuleTag
36+
import com.lambda.network.LambdaAPI
37+
import com.lambda.network.NetworkManager
3638
import com.lambda.threading.runSafe
3739
import com.lambda.util.Communication.info
3840
import com.lambda.util.Diagnostics.gatherDiagnostics
@@ -100,15 +102,43 @@ object MenuBar {
100102
}
101103

102104
private fun ImGuiBuilder.buildLambdaMenu() {
103-
menuItem("New Profile...", enabled = false) {
104-
// ToDo (New Profile):
105-
// - Open a modal "New Profile" with:
106-
// [Profile Name] text input
107-
// [Template] combo: Empty / Recommended Defaults / Copy from Current
108-
// [Include HUD Layout] checkbox
109-
// - On Create: instantiate and activate the profile, optionally copying values from current.
110-
// - On Cancel: close modal with no changes.
105+
menu("Safe Config...") {
106+
menuItem("Save All Configs") {
107+
Configuration.configurations.forEach { it.trySave(true) }
108+
info("Saved ${Configuration.configurations.size} configuration files.")
109+
}
110+
Configuration.configurations.forEach { config ->
111+
menuItem("Save ${config.configName}") {
112+
config.trySave(true)
113+
info("Saved ${config.configName}")
114+
}
115+
}
116+
}
117+
menu("Load Config...") {
118+
menuItem("Load All Configs") {
119+
Configuration.configurations.forEach { it.tryLoad() }
120+
info("Loaded ${Configuration.configurations.size} configuration files.")
121+
}
122+
Configuration.configurations.forEach { config ->
123+
menuItem("Load ${config.configName}") {
124+
config.tryLoad()
125+
info("Loaded ${config.configName}")
126+
}
127+
}
128+
}
129+
separator()
130+
menu("Settings") {
131+
menu("HUD Settings") {
132+
buildConfigSettingsContext(HudGuiLayout)
133+
}
134+
menu("GUI Settings") {
135+
buildConfigSettingsContext(ClickGuiLayout)
136+
}
137+
menu("Lambda API Settings") {
138+
buildConfigSettingsContext(LambdaAPI)
139+
}
111140
}
141+
separator()
112142
menu("Open Folder") {
113143
menuItem("Open Lambda Folder") {
114144
Util.getOperatingSystem().open(FolderRegister.lambda)
@@ -136,15 +166,15 @@ object MenuBar {
136166
}
137167
}
138168
separator()
139-
menuItem("Save Configs") {
140-
Configuration.configurations.forEach { it.trySave(true) }
141-
info("Saved ${Configuration.configurations.size} configuration files.")
142-
}
143-
menuItem("Load Configs") {
144-
Configuration.configurations.forEach { it.tryLoad() }
145-
info("Loaded ${Configuration.configurations.size} configuration files.")
169+
menuItem("New Profile...", enabled = false) {
170+
// ToDo (New Profile):
171+
// - Open a modal "New Profile" with:
172+
// [Profile Name] text input
173+
// [Template] combo: Empty / Recommended Defaults / Copy from Current
174+
// [Include HUD Layout] checkbox
175+
// - On Create: instantiate and activate the profile, optionally copying values from current.
176+
// - On Cancel: close modal with no changes.
146177
}
147-
separator()
148178
menuItem("Import Profile...", enabled = false) {
149179
// ToDo (Import Profile):
150180
// - Show a file picker for profile file(s).
@@ -189,6 +219,9 @@ object MenuBar {
189219
menuItem("About...") {
190220
aboutRequested = true
191221
}
222+
menuItem("Developer Mode", selected = ClickGuiLayout.developerMode) {
223+
ClickGuiLayout.developerMode = !ClickGuiLayout.developerMode
224+
}
192225
separator()
193226
menuItem("Close GUI", "Esc") { LambdaScreen.close() }
194227
menuItem("Exit Client") { mc.scheduleStop() }

src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.lambda.gui.MenuBar.buildMenuBar
3030
import com.lambda.gui.components.QuickSearch.renderQuickSearch
3131
import com.lambda.gui.dsl.ImGuiBuilder.buildLayout
3232
import com.lambda.module.ModuleRegistry
33+
import com.lambda.module.tag.ModuleTag
3334
import com.lambda.module.tag.ModuleTag.Companion.shownTags
3435
import com.lambda.sound.LambdaSound
3536
import com.lambda.sound.SoundManager.play
@@ -54,6 +55,7 @@ import java.awt.Color
5455
object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
5556
override val name = "GUI"
5657
var open = false
58+
var developerMode = false
5759
val keybind by setting("Keybind", KeyCode.Y) { false }
5860

5961
private enum class Group(override val displayName: String) : NamedEnum {
@@ -193,7 +195,10 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
193195
if (!open) return@listen
194196

195197
buildLayout {
196-
shownTags.forEach { tag ->
198+
val tags = if (developerMode) shownTags + ModuleTag.DEBUG else shownTags
199+
if (tags.isEmpty()) return@buildLayout
200+
201+
tags.forEach { tag ->
197202
window(tag.name, flags = AlwaysAutoResize) {
198203
ModuleRegistry.modules
199204
.filter { it.tag == tag }
@@ -204,8 +209,10 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
204209
buildMenuBar()
205210
renderQuickSearch()
206211

207-
ImGui.showDemoWindow()
208-
ImPlot.showDemoWindow()
212+
if (developerMode) {
213+
ImGui.showDemoWindow()
214+
ImPlot.showDemoWindow()
215+
}
209216
}
210217
}
211218

src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,8 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
311311
val rounding = if (baseRadius > 0f) baseRadius else style.windowRounding
312312
val inflate = hudOutlineCornerInflate
313313

314-
// Disable window clipping for these strokes while keeping window Z-order
315314
draw.pushClipRectFullScreen()
316315

317-
// Slightly grow the visual size so arcs feel bigger
318316
val haloRadius = (rounding + inflate + 0.5f * hudOutlineHaloThickness + 1.0f).coerceAtLeast(0f)
319317
val borderRadius = (rounding + 0.5f * hudOutlineBorderThickness + 0.75f).coerceAtLeast(0f)
320318

src/main/kotlin/com/lambda/module/tag/ModuleTag.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ data class ModuleTag(override val name: String) : Nameable {
4545
val DEBUG = ModuleTag("Debug")
4646
val HUD = ModuleTag("Hud")
4747

48-
val defaults = setOf(COMBAT, MOVEMENT, RENDER, PLAYER, NETWORK, DEBUG, CLIENT, HUD)
48+
val defaults = setOf(COMBAT, MOVEMENT, RENDER, PLAYER, NETWORK, CLIENT, HUD)
4949

5050
val shownTags = defaults.toMutableSet()
5151

src/main/kotlin/com/lambda/network/CapeManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.lambda.core.Loadable
2424
import com.lambda.event.events.WorldEvent
2525
import com.lambda.event.listener.SafeListener.Companion.listen
2626
import com.lambda.graphics.texture.TextureUtils
27-
import com.lambda.module.modules.client.Network.cdn
27+
import com.lambda.network.LambdaAPI.cdn
2828
import com.lambda.network.api.v1.endpoints.getCape
2929
import com.lambda.network.api.v1.endpoints.getCapes
3030
import com.lambda.network.api.v1.endpoints.setCape

src/main/kotlin/com/lambda/module/modules/client/Network.kt renamed to src/main/kotlin/com/lambda/network/LambdaAPI.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
package com.lambda.module.modules.client
18+
package com.lambda.network
1919

2020
import com.lambda.Lambda.LOG
2121
import com.lambda.Lambda.mc
22+
import com.lambda.config.Configurable
23+
import com.lambda.config.configurations.LambdaConfig
2224
import com.lambda.event.events.ClientEvent
2325
import com.lambda.event.events.ConnectionEvent
2426
import com.lambda.event.events.ConnectionEvent.Connect.Login.EncryptionResponse
2527
import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe
2628
import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafeConcurrently
27-
import com.lambda.module.Module
28-
import com.lambda.module.tag.ModuleTag
29-
import com.lambda.network.NetworkManager
3029
import com.lambda.network.NetworkManager.updateToken
3130
import com.lambda.network.api.v1.endpoints.login
3231
import com.lambda.util.StringUtils.hash
@@ -42,13 +41,9 @@ import net.minecraft.text.Text
4241
import java.math.BigInteger
4342
import kotlin.jvm.optionals.getOrElse
4443

44+
object LambdaAPI : Configurable(LambdaConfig) {
45+
override val name = "api"
4546

46-
object Network : Module(
47-
name = "Network",
48-
description = "Lambda Authentication",
49-
tag = ModuleTag.CLIENT,
50-
enabledByDefault = true,
51-
) {
5247
val authServer by setting("Auth Server", "auth.lambda-client.org")
5348
val apiUrl by setting("API Server", "https://api.lambda-client.org")
5449
val apiVersion by setting("API Version", ApiVersion.V1)
@@ -107,4 +102,4 @@ object Network : Module(
107102

108103
override fun toString() = value
109104
}
110-
}
105+
}

src/main/kotlin/com/lambda/network/NetworkManager.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ package com.lambda.network
1919

2020
import com.lambda.Lambda.mc
2121
import com.lambda.config.Configurable
22-
import com.lambda.config.configurations.LambdaConfig
22+
import com.lambda.config.configurations.SecretsConfig
2323
import com.lambda.core.Loadable
2424
import com.lambda.network.api.v1.models.Authentication
2525
import com.lambda.network.api.v1.models.Authentication.Data
2626
import com.lambda.util.StringUtils.base64UrlDecode
2727
import com.lambda.util.StringUtils.json
2828
import com.lambda.util.collections.updatableLazy
2929

30-
object NetworkManager : Configurable(LambdaConfig), Loadable {
30+
object NetworkManager : Configurable(SecretsConfig), Loadable {
3131
override val name = "network"
3232

33-
var accessToken by setting("access_token", ""); private set
33+
var accessToken by setting("access_token", "") { false }; private set
3434

3535
val isValid: Boolean
3636
get() = mc.gameProfile.name == auth.value?.data?.name &&
@@ -53,7 +53,6 @@ object NetworkManager : Configurable(LambdaConfig), Loadable {
5353
auth.update()
5454
}
5555

56-
5756
override fun load(): String {
5857
auth.update()
5958

src/main/kotlin/com/lambda/network/api/v1/endpoints/GetCape.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
package com.lambda.network.api.v1.endpoints
1919

20-
import com.lambda.module.modules.client.Network.apiUrl
21-
import com.lambda.module.modules.client.Network.apiVersion
20+
import com.lambda.network.LambdaAPI.apiUrl
21+
import com.lambda.network.LambdaAPI.apiVersion
2222
import com.lambda.network.LambdaHttp
2323
import com.lambda.network.api.v1.models.Cape
2424
import io.ktor.client.call.*

src/main/kotlin/com/lambda/network/api/v1/endpoints/GetCapes.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
package com.lambda.network.api.v1.endpoints
1919

20-
import com.lambda.module.modules.client.Network.apiUrl
21-
import com.lambda.module.modules.client.Network.apiVersion
20+
import com.lambda.network.LambdaAPI.apiUrl
21+
import com.lambda.network.LambdaAPI.apiVersion
2222
import com.lambda.network.LambdaHttp
2323
import com.lambda.network.api.v1.models.Cape
2424
import io.ktor.client.call.*

0 commit comments

Comments
 (0)