-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
22 changed files
with
742 additions
and
830 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,14 @@ | ||
// Project generated by Kotlin Multiplatform Wizard | ||
{ | ||
"spec": { | ||
"template_id": "kmt", | ||
"targets": { | ||
"web": { | ||
"ui": [ | ||
"compose" | ||
] | ||
} | ||
} | ||
}, | ||
"timestamp": "2024-02-16T06:46:50.981192499Z" | ||
} |
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,5 +1,5 @@ | ||
# OverrunGL Artifacts Customizer | ||
# OverrunGL Modules Customizer | ||
|
||
[![pages-build-deployment](https://github.com/Over-Run/overrungl-gen/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/Over-Run/overrungl-gen/actions/workflows/pages/pages-build-deployment) | ||
|
||
The customizer for OverrunGL is available on [GitHub](https://over-run.github.io/overrungl-gen/). | ||
The customizer for [OverrunGL](https://github.com/Over-Run/overrungl) is available on [GitHub](https://over-run.github.io/overrungl-gen/). |
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,63 +1,6 @@ | ||
plugins { | ||
kotlin("multiplatform") version "1.9.0" | ||
application | ||
} | ||
|
||
group = "io.github.over-run" | ||
version = "0.2.2" | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
jvmToolchain(17) | ||
withJava() | ||
} | ||
js { | ||
binaries.executable() | ||
browser { | ||
commonWebpackConfig { | ||
cssSupport { | ||
enabled.set(true) | ||
} | ||
} | ||
} | ||
} | ||
sourceSets { | ||
val commonMain by getting | ||
val commonTest by getting | ||
val jvmMain by getting { | ||
dependencies { | ||
implementation("io.ktor:ktor-server-netty:2.0.2") | ||
implementation("io.ktor:ktor-server-html-builder-jvm:2.0.2") | ||
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2") | ||
} | ||
} | ||
val jvmTest by getting | ||
val jsMain by getting { | ||
dependencies { | ||
implementation("org.jetbrains.kotlin-wrappers:kotlin-react:18.2.0-pre.346") | ||
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:18.2.0-pre.346") | ||
implementation("org.jetbrains.kotlin-wrappers:kotlin-emotion:11.9.3-pre.346") | ||
} | ||
} | ||
val jsTest by getting | ||
} | ||
} | ||
|
||
application { | ||
mainClass.set("io.github.overrun.application.ServerKt") | ||
} | ||
|
||
tasks.named<Copy>("jvmProcessResources") { | ||
val jsBrowserDistribution = tasks.named("jsBrowserDistribution") | ||
from(jsBrowserDistribution) | ||
} | ||
|
||
tasks.named<JavaExec>("run") { | ||
dependsOn(tasks.named<Jar>("jvmJar")) | ||
classpath(tasks.named<Jar>("jvmJar")) | ||
// this is necessary to avoid the plugins to be loaded multiple times | ||
// in each subproject's classloader | ||
alias(libs.plugins.jetbrainsCompose) apply false | ||
alias(libs.plugins.kotlinMultiplatform) apply false | ||
} |
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,40 @@ | ||
import org.jetbrains.compose.ExperimentalComposeLibrary | ||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat | ||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl | ||
|
||
plugins { | ||
alias(libs.plugins.kotlinMultiplatform) | ||
|
||
alias(libs.plugins.jetbrainsCompose) | ||
} | ||
|
||
kotlin { | ||
@OptIn(ExperimentalWasmDsl::class) | ||
wasmJs { | ||
moduleName = "composeApp" | ||
browser { | ||
commonWebpackConfig { | ||
outputFileName = "composeApp.js" | ||
} | ||
} | ||
binaries.executable() | ||
} | ||
|
||
sourceSets { | ||
|
||
commonMain.dependencies { | ||
implementation(compose.runtime) | ||
implementation(compose.foundation) | ||
implementation(compose.material) | ||
implementation(compose.ui) | ||
@OptIn(ExperimentalComposeLibrary::class) | ||
implementation(compose.components.resources) | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
compose.experimental { | ||
web.application {} | ||
} |
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,154 @@ | ||
import LangType.GRADLE_GROOVY | ||
import LangType.GRADLE_KOTLIN | ||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.* | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.ContentCopy | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.em | ||
import kotlinx.browser.localStorage | ||
import kotlinx.browser.window | ||
import org.jetbrains.compose.resources.ExperimentalResourceApi | ||
import org.jetbrains.compose.resources.Font | ||
import org.jetbrains.compose.resources.FontResource | ||
|
||
@Composable | ||
fun App() { | ||
MaterialTheme { | ||
Scaffold(topBar = { | ||
TopAppBar(title = { | ||
Text("OverrunGL Modules Customizer") | ||
Text("v0.3.0", fontSize = 0.8.em) | ||
}) | ||
}) { | ||
Surface(modifier = Modifier.fillMaxSize()) { | ||
Customizer() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalResourceApi::class) | ||
@Composable | ||
private fun Customizer() { | ||
val JetBrainsMono = FontFamily( | ||
Font(FontResource("jetbrainsmono_regular.ttf"), weight = FontWeight.Normal) | ||
) | ||
var langType by remember { | ||
mutableStateOf( | ||
langTypeFromString(localStorage.getItem("langType")) ?: GRADLE_KOTLIN | ||
) | ||
} | ||
val generatedCode = remember { | ||
when (langType) { | ||
GRADLE_GROOVY -> generateGroovy() | ||
GRADLE_KOTLIN -> generateKotlin() | ||
} | ||
} | ||
|
||
Column(modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) { | ||
// disclaimer | ||
Text( | ||
"Disclaimer: this customizer uses experimental features and might occur errors when any key is pressed", | ||
fontWeight = FontWeight.Bold | ||
) | ||
|
||
// select the build type | ||
Row { | ||
Button(onClick = {}, modifier = Modifier.padding(all = 32.dp)) { | ||
Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
Text("Snapshot", fontSize = 2.em) | ||
Text("Unstable build", fontStyle = FontStyle.Italic) | ||
Text("$V_LATEST-SNAPSHOT") | ||
} | ||
} | ||
} | ||
|
||
Surface(modifier = Modifier.fillMaxSize().padding(all = 16.dp)) { | ||
// inside | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
border = BorderStroke(width = 2.dp, color = MaterialTheme.colors.onSurface) | ||
) { | ||
Column { | ||
Row(modifier = Modifier.fillMaxWidth().padding(all = 16.dp)) { | ||
@Composable | ||
inline fun optionTitle(text: String) { | ||
Text(text, fontSize = 1.2.em, fontWeight = FontWeight.Bold) | ||
} | ||
|
||
Column { | ||
// natives | ||
optionTitle("Natives") | ||
} | ||
|
||
Column(modifier = Modifier.padding(start = 16.dp, end = 16.dp)) { | ||
// addons | ||
optionTitle("Addons") | ||
|
||
// version | ||
optionTitle("Version") | ||
} | ||
|
||
Column { | ||
// modules | ||
optionTitle("Modules") | ||
} | ||
} | ||
|
||
// generated code | ||
Column(modifier = Modifier.padding(all = 16.dp)) { | ||
Row { | ||
langTypeButton(GRADLE_GROOVY) { langType = it } | ||
langTypeButton(GRADLE_KOTLIN) { langType = it } | ||
} | ||
Surface( | ||
modifier = Modifier.fillMaxWidth(), | ||
border = ButtonDefaults.outlinedBorder | ||
) { | ||
// SelectionContainer { | ||
Text( | ||
generatedCode, modifier = Modifier.padding(2.dp), fontFamily = JetBrainsMono | ||
) | ||
// } | ||
} | ||
Button(onClick = { | ||
window.navigator.clipboard.writeText(generatedCode) | ||
}) { | ||
Icon(Icons.Default.ContentCopy, contentDescription = null) | ||
Text("Copy to clipboard") | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
fun generateGroovy(): String = buildString { | ||
appendLine("dependencies {") | ||
append("}") | ||
} | ||
|
||
fun generateKotlin(): String = buildString { | ||
appendLine("dependencies {") | ||
append("}") | ||
} | ||
|
||
@Composable | ||
fun langTypeButton(langType: LangType, onClick: (LangType) -> Unit) { | ||
OutlinedButton(onClick = { | ||
onClick(langType) | ||
localStorage.setItem("langType", langType.name) | ||
}) { | ||
Text(langType.typeName) | ||
} | ||
} |
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,6 @@ | ||
/** | ||
* @author squid233 | ||
* @since 0.3.0 | ||
*/ | ||
enum class Binding { | ||
} |
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,14 @@ | ||
/** | ||
* @author squid233 | ||
* @since 0.3.0 | ||
*/ | ||
enum class LangType(val typeName: String) { | ||
GRADLE_GROOVY("Gradle (Groovy)"), | ||
GRADLE_KOTLIN("Gradle (Kotlin)"), | ||
} | ||
|
||
fun langTypeFromString(name: String?): LangType? = when (name) { | ||
"GRADLE_GROOVY" -> LangType.GRADLE_GROOVY | ||
"GRADLE_KOTLIN" -> LangType.GRADLE_KOTLIN | ||
else -> null | ||
} |
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,11 @@ | ||
/** | ||
* @author squid233 | ||
* @since 0.3.0 | ||
*/ | ||
class Version(val versionName: String) { | ||
override fun toString(): String = versionName | ||
} | ||
|
||
val V0_1_0 = Version("0.1.0") | ||
|
||
val V_LATEST = V0_1_0 |
Oops, something went wrong.