Skip to content

Commit

Permalink
feat(mindustry): Improved changelog command and added it in the welco…
Browse files Browse the repository at this point in the history
…me menu
  • Loading branch information
phinner committed Dec 28, 2024
1 parent fd425b1 commit b5734e7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import net.kyori.indra.git.IndraGitExtension
import org.eclipse.jgit.lib.Constants
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.getByType

@CacheableTask
open class GenerateImperiumChangelog : DefaultTask() {

@OutputFile
Expand Down
1 change: 1 addition & 0 deletions imperium-mindustry/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ val generateResources by tasks.registering {
}

val generateChangelog by tasks.registering(GenerateImperiumChangelog::class) {
outputs.upToDateWhen { false }
target = temporaryDir.resolve("imperium-changelog.txt")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ import com.xpdustry.distributor.api.component.TextComponent.text
import com.xpdustry.distributor.api.component.style.ComponentColor
import com.xpdustry.imperium.common.application.ImperiumApplication
import com.xpdustry.imperium.common.command.ImperiumCommand
import com.xpdustry.imperium.common.inject.InstanceManager
import com.xpdustry.imperium.common.inject.get
import com.xpdustry.imperium.common.version.ImperiumVersion
import com.xpdustry.imperium.mindustry.command.annotation.ClientSide
import com.xpdustry.imperium.mindustry.command.annotation.ServerSide
import com.xpdustry.imperium.mindustry.translation.GRAY
import java.io.Reader

class ChangelogCommand : ImperiumApplication.Listener {
class ChangelogCommand(instances: InstanceManager) : ImperiumApplication.Listener {

private val version = instances.get<ImperiumVersion>()

private val changelog: Component

Expand All @@ -53,18 +58,22 @@ class ChangelogCommand : ImperiumApplication.Listener {

val builder = components()
val none = text("None", GRAY)
builder.append(newline())

builder.append(text("Changelog for Imperium v$version", ComponentColor.GREEN))
builder.append(newline(), newline())
builder.append(text("Features and Changes", ComponentColor.ACCENT))
builder.append(newline())
builder.append(newline(), newline())
if (features.isNotEmpty()) {
features.forEach { feature -> builder.append(text(" - "), text(feature), newline()) }
features.forEach { feature ->
builder.append(text(" - "), text(feature), newline(), newline())
}
} else {
builder.append(none)
builder.append(none, newline(), newline())
}
builder.append(text("Bugfixes", ComponentColor.ACCENT))
builder.append(newline())
builder.append(newline(), newline())
if (bugfixes.isNotEmpty()) {
bugfixes.forEach { fix -> builder.append(text(" - "), text(fix), newline()) }
bugfixes.forEach { fix -> builder.append(text(" - "), text(fix), newline(), newline()) }
} else {
builder.append(none)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ fun gui_welcome_button_rules(): Component =

fun gui_welcome_button_discord(): Component = text(Iconc.discord + " Discord", BLURPLE)

fun gui_welcome_button_changelog(): Component =
components(
GREEN, text(Iconc.book), space(), translatable("imperium.gui.welcome.button.changelog"))

fun gui_rules_title(): Component = translatable("imperium.gui.rules.title")

fun gui_rules_content(): Component =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.xpdustry.imperium.mindustry.misc.runMindustryThread
import com.xpdustry.imperium.mindustry.translation.gui_close
import com.xpdustry.imperium.mindustry.translation.gui_rules_content
import com.xpdustry.imperium.mindustry.translation.gui_rules_title
import com.xpdustry.imperium.mindustry.translation.gui_welcome_button_changelog
import com.xpdustry.imperium.mindustry.translation.gui_welcome_button_discord
import com.xpdustry.imperium.mindustry.translation.gui_welcome_button_rules
import com.xpdustry.imperium.mindustry.translation.gui_welcome_content
Expand Down Expand Up @@ -68,6 +69,8 @@ class WelcomeListener(instances: InstanceManager) : ImperiumApplication.Listener
MenuOption.of(
gui_welcome_button_discord(),
Action.audience { it.openURI(DISCORD_INVITATION_LINK.toURI()) }))
pane.grid.addRow(
MenuOption.of(gui_welcome_button_changelog(), Action.command("changelog")))
pane.grid.addRow(MenuOption.of(gui_close(), Window::hide))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ imperium.gui.rules.title=Da rules
imperium.gui.user-settings.description=Change your settings by clicking on the corresponding buttons.
imperium.gui.user-settings.title=User settings
imperium.gui.welcome.button.rules=Rules
imperium.gui.welcome.button.changelog=Recent Changes
imperium.gui.welcome.content.body=Have fun on our server network!
imperium.gui.welcome.content.footer=You can disable this message with the /settings command.
imperium.gui.welcome.content.header=Welcome to {0}
Expand Down

0 comments on commit b5734e7

Please sign in to comment.