Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ src-gen/
setup.log
local.properties
wurstpack_compiler.zip
buildproject/
compiled.j.txt
myname/
ptrtestproject/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add your local test folders to gitignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are all generated by the project itself - what do you mean "local test folders"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes u think

compiled.j.txt
myname/
ptrtestproject/

would be files generated by this project?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be files generated by this project?!

The project has tests, right? What kind of tests does it have? Wurst tests

In fact I know these are generated by some gradle task, because otherwise I wouldn't have these files to ignore

temp/
testproject/
.classpath
.project
.settings/
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.9.3'
compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.9'
compile 'com.github.inwc3:wc3libs:fd4b2fd5aa'
compile 'com.github.Frotty:SwingDarkFlatTable:a033300526'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'io.github.microutils:kotlin-logging:1.6.26'
Expand All @@ -41,6 +42,12 @@ dependencies {
testCompile 'org.testng:testng:6.14.3'
}

allprojects {
dependencies {
implementation 'com.github.inwc3:wc3libs:fd4b2fd5aa'
}
}

test {
useTestNG()
}
Expand Down
49 changes: 14 additions & 35 deletions src/main/kotlin/ui/MainWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import config.CONFIG_FILE_NAME
import config.WurstProjectBuildMapData
import config.WurstProjectConfig
import config.WurstProjectConfigData
import de.ralleytn.simple.registry.Registry
import file.CompileTimeInfo
import file.SetupApp
import global.InstallationManager
import global.Log
import mu.KotlinLogging
import net.moonlightflower.wc3libs.port.StdGameExeFinder
import net.ConnectionManager
import net.NetStatus
import tablelayout.Table
Expand Down Expand Up @@ -227,15 +227,24 @@ object MainWindow : JFrame() {
}

private fun titleEvents(minimize: JButton, exit: JButton) {
minimize.addActionListener { e -> state = Frame.ICONIFIED }
exit.addActionListener { e ->
minimize.addActionListener { _ -> state = Frame.ICONIFIED }
exit.addActionListener { _ ->
dispose()
exitProcess(0)
}
}

private var projectRootFile: File = File(".")

private fun discoverWc3Path(): Optional<String> {
try {
return Optional.of(StdGameExeFinder().find().path)
} catch (e: Exception) {
log.info("Failed to discover wc3path with exception %s".format(e.toString()))
return Optional.empty()
}
}

private fun createConfigTable() {
val that = this
val configTable = Table()
Expand Down Expand Up @@ -266,7 +275,7 @@ object MainWindow : JFrame() {
if (projectNameTF.text.isEmpty()) {
btnCreate.isEnabled = false
} else {
projectRootTF.text = projectRootFile?.absolutePath + File.separator + projectNameTF.text
projectRootTF.text = projectRootFile.absolutePath + File.separator + projectNameTF.text
if (!disabled) {
btnCreate.isEnabled = true
}
Expand Down Expand Up @@ -317,23 +326,7 @@ object MainWindow : JFrame() {
}
}
})
if (System.getProperty("os.name").startsWith("Windows")) {
try {
val key = Registry.getKey(Registry.HKEY_CURRENT_USER + "\\SOFTWARE\\Blizzard Entertainment\\Warcraft III")
var wc3Path = key?.getValueByName("InstallPath")?.rawValue
if (wc3Path != null) {
if (!wc3Path.endsWith(File.separator)) wc3Path += File.separator
val gameFolder = Paths.get(wc3Path)
if (Files.exists(gameFolder)) {
gamePathTF.text = wc3Path
}
} else {
checkDefaultWinLocation()
}
} catch (e: Exception) {
checkDefaultWinLocation()
}
}
discoverWc3Path().map({ path -> gamePathTF.text = path })
gameTF.addCell(selectGamePath).height(24f).pad(0f, 2f, 0f, 2f)

configTable.addCell(gameTF).growX()
Expand All @@ -358,20 +351,6 @@ object MainWindow : JFrame() {
contentTable.addCell(configTable).growX().pad(2f)
}

private fun checkDefaultWinLocation() {
var gameFolder = Paths.get(System.getenv("ProgramFiles"))?.resolve("Warcraft III")
if (gameFolder != null && Files.exists(gameFolder)) {
gamePathTF.text = gameFolder.toAbsolutePath().toString()
} else {
gameFolder = Paths.get(System.getenv("ProgramFiles") + " (x86)")?.resolve("Warcraft III")
if (gameFolder != null && Files.exists(gameFolder)) {
gamePathTF.text = gameFolder.toAbsolutePath().toString()
} else {
log.warn("Didn't find warcraft installation.")
}
}
}

private fun handleImport() {
try {
val buildFile = importChooser.selectedFile.toPath()
Expand Down