Skip to content

Commit

Permalink
fixed some bugs, added better dynamic change of panels inside
Browse files Browse the repository at this point in the history
  • Loading branch information
justADeni committed Mar 30, 2023
1 parent 525bfcd commit 2909ef5
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 24 deletions.
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Manifest-Version: 1.0
Main-Class: main.kotlin.MainKt
Class-Path: \main\kotlin\Main.kt
Class-Path: src/main/kotlin/Main.kt

72 changes: 67 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,36 @@
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>

<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>

<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>

</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.8.10</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
Expand All @@ -58,12 +80,14 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -76,6 +100,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>8</source>
<target>8</target>
Expand All @@ -84,6 +109,37 @@
</plugins>
</build>

<!--build>
<finalName>my-project-name</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build-->

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down Expand Up @@ -122,16 +178,22 @@
<artifactId>flatlaf-intellij-themes</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<!--dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependency-->
<dependency>
<groupId>com.github.justADeni</groupId>
<artifactId>ChemRecipeIcon</artifactId>
<version>3952c473a6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.justadeni</groupId>
<artifactId>ChemRecipe</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/misc/Inst.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import panels.Menu
import panels.Right
import panels.SEditor
import java.awt.Font
import java.nio.file.Path
import javax.swing.JFrame
import javax.swing.JLabel
import javax.swing.SwingUtilities
Expand All @@ -32,6 +33,10 @@ object Inst {
val menu = Menu()
val listActions = ListActions()

//fun paintOnee(path: Path, num : Int){
// Painter.paintOne(path, num)
//}

fun refresh(){
SwingUtilities.updateComponentTreeUI(jframe)
sEditor.jPanel.repaint()
Expand Down
38 changes: 24 additions & 14 deletions src/main/kotlin/misc/Saver.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package main.kotlin.misc

import Painter
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import main.kotlin.tooltip.CustomLabel
import java.io.File
import java.io.FileInputStream
Expand Down Expand Up @@ -100,12 +104,12 @@ object Saver {
fun reloadall(){
Inst.right.list.removeAll()
Inst.right.demoList.removeAllElements()

Files.walk(Paths.get(Inst.loader.recipeFolder.path)).use {
paths -> paths.filter { Files.isRegularFile(it) }
.forEach {
val recipeName = it.fileName.toString().split(".chemrecipe")[0]
Inst.right.demoList.addElement(recipeName)

compoundLoadCheck(it)
/*
val cLine : String = Files.lines(it).use { lines -> lines.skip(10).findFirst().get() }
Expand All @@ -129,6 +133,7 @@ object Saver {
*/
}
}

enoughCompoundsCheck()
}

Expand All @@ -150,6 +155,15 @@ object Saver {
Painter.paintOne(Inst.loader.compoundsFolder.toPath(), num)
Inst.left.loadCompound(num)
}
var loaded = false
for (compound in Inst.left.listchemassets) {
if (compound.info == parts[1]) {
loaded = true
break
}
}
if (!loaded)
Inst.left.loadCompound(num)


for (compound in Inst.left.listchemassets) {
Expand Down Expand Up @@ -215,34 +229,30 @@ object Saver {
compoundsChecking = true

var a = 0
var b = 0
for (compound in Inst.left.listchemassets){
if (compound.toolTipText.contains("Element"))
continue

if (compound.toolTipText.contains("Undefined"))
a++
else
b++
}

//println("a: $a")
//println("b: $b")
println("a: $a")

if (a < 5){
var plus = 0
for (i in a+b+1..a+(5-a)+b){
var j = i + plus
while (File(Inst.loader.compoundsFolder.path + "/$j.png").exists()){
j++
plus++
val listFiles : Array<String> = Inst.loader.compoundsFolder.list() as Array<String>
for (i in 10..3136){
if (!listFiles.contains("$i.png")){
Painter.paintOne(Inst.loader.compoundsFolder.toPath(), i)
Inst.left.loadCompound(i)
break
}
Painter.paintOne(Inst.loader.compoundsFolder.toPath(), j)
Inst.left.loadCompound(i)
}
}

Inst.left.changeSizeDynamically(Inst.left.chemassetpanel)
Inst.left.refreshChems()

compoundsChecking = false
}
}
16 changes: 12 additions & 4 deletions src/main/kotlin/panels/Left.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import java.awt.GridBagConstraints
import java.awt.GridBagLayout
import java.awt.Image
import java.io.File
import java.nio.file.Path
import java.util.*
import javax.swing.*
import kotlin.math.ceil
Expand Down Expand Up @@ -56,7 +57,9 @@ class Left(val jPanel: JPanel = JPanel()) {
}

fun loadCompound(num : Int){
val file = File(Inst.loader.compoundsFolder.path + "/$num.png")
println("loadCompound loading $num")

var file = File(Inst.loader.compoundsFolder.path + "/$num.png")
val label = CompoundLabel("Compound " + file.nameWithoutExtension)
label.icon = ImageIcon(ImageIcon(file.path).image.getScaledInstance(32,32,Image.SCALE_SMOOTH))
label.toolTipText = "Undefined Compound " + file.nameWithoutExtension
Expand Down Expand Up @@ -100,9 +103,14 @@ class Left(val jPanel: JPanel = JPanel()) {
listchemassets.add(label.copyHandler())

}
val compoundNum = Inst.loader.compoundsFolder.list()?.size
for (i in 1..compoundNum!!){
val file = Inst.loader.getExactNumerical(Inst.loader.compoundsFolder, i)
//val compoundNum = Inst.loader.compoundsFolder.list()?.size
val fileNums = arrayListOf<Int>()
for (file in Inst.loader.compoundsFolder.listFiles()!!){
fileNums.add(file.nameWithoutExtension.toInt())
}
fileNums.sort()
for (num in fileNums){
val file = File(Inst.loader.compoundsFolder.path + "/$num.png")
val label = CompoundLabel("Compound " + file.nameWithoutExtension)
label.icon = ImageIcon(ImageIcon(file.path).image.getScaledInstance(32,32,Image.SCALE_SMOOTH))
label.toolTipText = "Undefined Compound " + file.nameWithoutExtension
Expand Down

0 comments on commit 2909ef5

Please sign in to comment.