Skip to content

Commit

Permalink
Add linter
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR committed Jun 22, 2019
1 parent 8cf72ca commit df465fb
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 27 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 1,8 @@
[*]
end_of_line=lf
insert_final_newline=true
indent_style=space
insert_final_newline=true

[*.{kt,kts}]
indent_size=4
max_line_length=140
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
plugins {
id 'application'
id 'org.jetbrains.kotlin.jvm' version '1.3.31'
id 'org.jmailen.kotlinter' version '1.26.0'
}

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,7 @@ object StatusView : View {
with(statusPanel) {
layout = BoxLayout(this, BoxLayout.LINE_AXIS)
border = BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(1, 0,0, 0, Color.GRAY),
BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY),
EmptyBorder(5, 5, 5, 5)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 152,7 @@ class LayersFilter {
} else {
LayersManager.removeVisibleType(childType)
}

LayersManager.removeHiddenType(childType)
} else {
LayersManager.removeVisibleType(childType)
Expand Down Expand Up @@ -189,7 189,7 @@ class LayersFilter {

addKeyListener(object : KeyAdapter() {
override fun keyPressed(e: KeyEvent) {
if(e.keyCode == KeyEvent.VK_ENTER) {
if (e.keyCode == KeyEvent.VK_ENTER) {
findAndSelectPath()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/github/spair/strongdmm/gui/map/Frame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ object Frame {
private const val DEFAULT_FRAMES_TO_UPD = 2 // To render everything properly we need 2 frames

private var updateCounter = DEFAULT_FRAMES_TO_UPD
private var isForced = false // Will enforce VisualComposer to provide new render instances
private var isForced = false // Will enforce VisualComposer to provide new render instances

fun update() {
updateCounter = DEFAULT_FRAMES_TO_UPD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 133,7 @@ class MapPipeline(private val canvas: Canvas) {
Display.setParent(canvas)
Display.create()
DmiProvider.initTextures()
startRenderLoop() // this is where the magic happens
startRenderLoop() // this is where the magic happens
DmiProvider.clearTextures()
RenderInstanceProvider.clearTextures()
VisualComposer.clearCache()
Expand All @@ -144,7 144,7 @@ class MapPipeline(private val canvas: Canvas) {
}

private fun startRenderLoop() {
glClearColor(0.25f, 0.25f, 0.5f , 1f)
glClearColor(0.25f, 0.25f, 0.5f, 1f)

glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 73,7 @@ object MapView : View, EnvCleanable {
return false
}

fun createAndShowTilePopup(x:Int, y: Int, fillInAction: (JPopupMenu) -> Unit) {
fun createAndShowTilePopup(x: Int, y: Int, fillInAction: (JPopupMenu) -> Unit) {
SwingUtilities.invokeLater {
tilePopup = JPopupMenu().apply {
isLightWeightPopupEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 38,7 @@ fun MapPipeline.findAndSelectItemUnderMouse(renderInstances: RenderInstances) {

val item = TileItemProvider.getByID(tileItemID)
val isOpaque = DmiProvider.getSpriteFromDmi(item.icon, item.iconState, item.dir)?.isOpaquePixel(pixelX, pixelY)
?: true // When there is no sprite for item we are using placeholder which is always opaque
?: true // When there is no sprite for item we are using placeholder which is always opaque

if (isOpaque) {
selectedItem = item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 67,7 @@ object MouseProcessor {

private fun handleTileSelection() {
if (KeyboardProcessor.isCtrlDown() && KeyboardProcessor.isShiftDown() || (KeyboardProcessor.isAltDown())) {
return // no tile selection with those modifiers
return // no tile selection with those modifiers
}

if (Mouse.isButtonDown(LMB)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 94,6 @@ class AddTileSelect : TileSelect {
val xPos = (coordPoint.x - 1) * iconSize
val yPos = (coordPoint.y - 1) * iconSize


glBegin(GL_LINE_LOOP)
run {
glVertex2i(xPos, yPos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 179,7 @@ object ObjectTreeView : View, EnvCleanable {

addKeyListener(object : KeyAdapter() {
override fun keyPressed(e: KeyEvent) {
if(e.keyCode == KeyEvent.VK_ENTER) {
if (e.keyCode == KeyEvent.VK_ENTER) {
findAndSelectPath(searchPath)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 1,10 @@
package io.github.spair.strongdmm.logic

import io.github.spair.dmm.io.reader.DmmReader
import io.github.spair.strongdmm.gui.*
import io.github.spair.strongdmm.gui.PrimaryFrame
import io.github.spair.strongdmm.gui.StatusView
import io.github.spair.strongdmm.gui.TabbedMapPanelView
import io.github.spair.strongdmm.gui.TabbedObjectPanelView
import io.github.spair.strongdmm.gui.instancelist.InstanceListView
import io.github.spair.strongdmm.gui.map.MapView
import io.github.spair.strongdmm.gui.menubar.MenuBarView
Expand All @@ -12,7 15,6 @@ import io.github.spair.strongdmm.logic.history.History
import io.github.spair.strongdmm.logic.map.Dmm
import io.github.spair.strongdmm.logic.map.TileItemProvider
import java.io.File
import javax.swing.SwingUtilities
import kotlin.concurrent.thread

object Environment {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/io/github/spair/strongdmm/logic/dme/models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 23,7 @@ class DmeItem(
TYPE_DATUM -> null
TYPE_ATOM -> TYPE_DATUM
TYPE_ATOM_MOVABLE, TYPE_AREA, TYPE_TURF -> TYPE_ATOM
TYPE_OBJ, TYPE_MOB -> TYPE_ATOM_MOVABLE
TYPE_OBJ, TYPE_MOB -> TYPE_ATOM_MOVABLE
else -> type.substringBeforeLast('/')
}
}
Expand Down Expand Up @@ -66,4 66,4 @@ class DmeItem(

// This 'isType' doesn't handle datum/atom and so on, since map editor doesn't place those types on the map,
// so additional checks would result into obsolete overhead.
fun isType(t1: String, t2: String) = t1.startsWith(t2)
fun isType(t1: String, t2: String) = t1.startsWith(t2)
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 140,3 @@ class Tile(val x: Int, val y: Int, private var tileItemsIDs: IntArray) {
return newTileItem
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 8,7 @@ object RenderInstanceStruct {

// Number of bytes for int32/float32 primitive type.
private const val SIZE: Int = 4
private const val FULL_STRUCT_CAPACITY: Long = SIZE * 14L // allocation size for 14 members
private const val FULL_STRUCT_CAPACITY: Long = SIZE * 14L // allocation size for 14 members

// Bytes offset for all (14) struct members.
private const val LOC_X_POS = SIZE * 0
Expand Down Expand Up @@ -105,4 105,3 @@ object RenderInstanceStruct {
return f.get(null) as Unsafe
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,14 38,20 @@ object VisualComposer {
}

fun composeFrame(
dmm: Dmm, xMapOff: Int, yMapOff: Int, horTilesNum: Int, verTilesNum: Int, forceUpdate: Boolean, drawAreasBorder: Boolean
dmm: Dmm,
xMapOff: Int,
yMapOff: Int,
horTilesNum: Int,
verTilesNum: Int,
forceUpdate: Boolean,
drawAreasBorder: Boolean
): RenderInstances {
// Use cached render instances
if (riCache != null
&& !forceUpdate
&& xMapOffPrev == xMapOff && yMapOffPrev == yMapOff
&& horTilesNumPrev == horTilesNum && verTilesNumPrev == verTilesNum
&& drawAreasBorderPrev == drawAreasBorder
if (riCache != null &&
!forceUpdate &&
xMapOffPrev == xMapOff && yMapOffPrev == yMapOff &&
horTilesNumPrev == horTilesNum && verTilesNumPrev == verTilesNum &&
drawAreasBorderPrev == drawAreasBorder
) return riCache!!

deallocateCache()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 14,8 @@ fun createGlTexture(img: BufferedImage): Int {
for (x in 0 until img.width) {
val pixel = pixels[y * img.width x]
put((pixel shr 16 and 0xFF).toByte()) // Red
put((pixel shr 8 and 0xFF).toByte()) // Green
put((pixel and 0xFF).toByte()) // Blue
put((pixel shr 8 and 0xFF).toByte()) // Green
put((pixel and 0xFF).toByte()) // Blue
put((pixel shr 24 and 0xFF).toByte()) // Alpha
}
}
Expand Down

0 comments on commit df465fb

Please sign in to comment.