@@ -38,8 +38,6 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {
38
38
39
39
var removeQueue = ArrayList <CrosshairEntry >()
40
40
41
- var moveQueue = ArrayList <MoveType >()
42
-
43
41
private var scroll = 0f
44
42
45
43
private var scrollTarget = 0f
@@ -67,7 +65,7 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {
67
65
}
68
66
resetButton.setClickAction {
69
67
runAsync {
70
- reset ()
68
+ clear ()
71
69
}
72
70
}
73
71
saveButton.setClickAction {
@@ -110,16 +108,6 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {
110
108
}
111
109
112
110
override fun draw (vg : Long , x : Int , y : Int , inputHandler : InputHandler ) {
113
- if (moveQueue.isNotEmpty()) {
114
- var x = 0
115
- var y = 0
116
- for (i in moveQueue) {
117
- x + = i.x
118
- y + = i.y
119
- }
120
- move(x, y)
121
- moveQueue.clear()
122
- }
123
111
124
112
for (posY in 0 .. <ModConfig .canvaSize) {
125
113
for (posX in 0.. <ModConfig .canvaSize) {
@@ -202,6 +190,12 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {
202
190
return bufferedImage
203
191
}
204
192
193
+ fun clear () {
194
+ for (i in pixels) {
195
+ i.isToggled = false
196
+ }
197
+ }
198
+
205
199
fun loadImage (image : BufferedImage ? , save : Boolean , entry : CrosshairEntry = CrosshairEntry ()): OneImage ? {
206
200
val loadedImage = OneImage (image)
207
201
val dimensionsSame = loadedImage.width == loadedImage.height
@@ -242,42 +236,11 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {
242
236
return image
243
237
}
244
238
245
- fun reset () {
246
- val newEntry = CrosshairEntry ()
247
- toBufferedImage(newEntry.img)?.let {
248
- loadImage(it, false , newEntry)
249
- }
250
- }
251
-
252
- fun move (x : Int , y : Int ) {
253
- val newPositions = HashMap <Pos , Int >()
254
- for (i in ModConfig .drawer) {
255
- val pos = indexToPos(i.key)
256
- val posX = pos.x + x
257
- val posY = pos.y + y
258
- pixels[i.key].isToggled = false
259
- if (posX !in 0 .. <ModConfig .canvaSize || posY ! in 0.. <ModConfig .canvaSize) continue
260
- newPositions[Pos (posX, posY)] = i.value
261
- }
262
- for (i in newPositions) {
263
- val index = i.key.y * 32 + i.key.x
264
- pixels[index].isToggled = true
265
- pixels[index].color = i.value
266
- }
267
- }
268
-
269
239
fun getElement (entry : CrosshairEntry ): PresetElement {
270
240
elements[entry] ? : elements.put(entry, PresetElement (entry))
271
241
return elements[entry]!!
272
242
}
273
243
274
- enum class MoveType (val x: Int , val y: Int ) {
275
- UP (0, - 1),
276
- DOWN (0, 1),
277
- LEFT (- 1, 0),
278
- RIGHT (1, 0)
279
- }
280
-
281
244
override fun finishUpAndClose () {
282
245
val image = saveFromDrawer(true ) ? : return
283
246
ModConfig .newCurrentCrosshair.img = toBase64(image.image)
@@ -288,18 +251,11 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {
288
251
289
252
override fun keyTyped (key : Char , keyCode : Int ) {
290
253
if (mc.currentScreen !is OneConfigGui ) return
291
- if (keyCode == UKeyboard .KEY_W ) moveQueue.add(MoveType .UP )
292
- if (keyCode == UKeyboard .KEY_S ) {
293
- if (UKeyboard .isCtrlKeyDown()) {
294
- runAsync {
295
- save(saveFromDrawer(false))
296
- }
297
- } else {
298
- moveQueue.add(MoveType .DOWN )
254
+ if (UKeyboard .isCtrlKeyDown() && keyCode == UKeyboard .KEY_S ) {
255
+ runAsync {
256
+ save(saveFromDrawer(false ))
299
257
}
300
258
}
301
- if (keyCode == UKeyboard .KEY_A ) moveQueue.add(MoveType .LEFT )
302
- if (keyCode == UKeyboard .KEY_D ) moveQueue.add(MoveType .RIGHT )
303
259
}
304
260
305
261
}
0 commit comments