Skip to content

Commit

Permalink
Extensive refactor from Java to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Larson committed Jun 19, 2024
1 parent a9ec247 commit 90fe904
Show file tree
Hide file tree
Showing 199 changed files with 9,730 additions and 11,246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ package com.projectswg.holocore.intents.support.global.chat
import com.projectswg.holocore.resources.support.global.player.Player
import me.joshlarson.jlcommon.control.Intent

data class ChatAvatarRequestIntent(val player: Player, val target: String, val requestType: RequestType) : Intent() {
enum class RequestType {
FRIEND_LIST,
TARGET_STATUS,
FRIEND_ADD_TARGET,
FRIEND_REMOVE_TARGET,
IGNORE_ADD_TARGET,
IGNORE_REMOVE_TARGET,
IGNORE_LIST
}
}
data class ChatAvatarGetTargetStatusIntent(val player: Player, val target: String) : Intent()
data class ChatAvatarGetFriendListIntent(val player: Player) : Intent()
data class ChatAvatarAddFriendIntent(val player: Player, val target: String) : Intent()
data class ChatAvatarRemoveFriendIntent(val player: Player, val target: String) : Intent()
data class ChatAvatarGetIgnoreListIntent(val player: Player) : Intent()
data class ChatAvatarAddIgnoreIntent(val player: Player, val target: String) : Intent()
data class ChatAvatarRemoveIgnoreIntent(val player: Player, val target: String) : Intent()
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import com.projectswg.holocore.resources.gameplay.crafting.resource.galactic.Gal
import com.projectswg.holocore.resources.gameplay.crafting.resource.galactic.RawResourceType
import com.projectswg.holocore.resources.support.data.server_info.StandardLog
import com.projectswg.holocore.resources.support.data.server_info.loader.ServerData.rawResources
import com.projectswg.holocore.resources.support.global.zone.sui.SuiButtons
import com.projectswg.holocore.resources.support.global.zone.sui.SuiListBox
import com.projectswg.holocore.resources.support.global.zone.sui.SuiMessageBox
import com.projectswg.holocore.resources.support.global.zone.sui.SuiWindow
Expand All @@ -66,7 +65,7 @@ class SampleLoopSession(private val creature: CreatureObject, private val survey
fun isMatching(creature: CreatureObject, surveyTool: TangibleObject, resource: GalacticResource?, sampleLocation: Location): Boolean {
if (this.sampleLocation.distanceTo(sampleLocation) >= 0.5 || this.sampleLocation.terrain != sampleLocation.terrain) return false // Too far away for the same session

return this.creature == creature && (this.surveyTool == surveyTool) && this.resource.equals(resource)
return this.creature == creature && (this.surveyTool == surveyTool) && this.resource == resource
}

@get:Synchronized
Expand All @@ -85,7 +84,7 @@ class SampleLoopSession(private val creature: CreatureObject, private val survey
* Attempts to start the sample loop session with the specified executor. If the loop is unable to start, this function returns false; otherwise this function returns true.
*
* @param executor the executor for the loop to run on
* @return TRUE if the sample loop has begin, FALSE otherwise
* @return TRUE if the sample loop has begun, FALSE otherwise
*/
@Synchronized
fun startSession(executor: ScheduledThreadPool): Boolean {
Expand Down Expand Up @@ -166,21 +165,26 @@ class SampleLoopSession(private val creature: CreatureObject, private val survey
}

private fun openConcentrationWindow() {
val window = SuiMessageBox(SuiButtons.OK_CANCEL, "@survey:cnode_t", "@survey:cnode_d")
window.setProperty("btnOk", "Text", "@survey:cnode_2")
window.setProperty("btnCancel", "Text", "@survey:cnode_1")
window.addOkButtonCallback("okButton") { _: SuiEvent?, parameters: Map<String?, String?>? ->
val index = SuiListBox.getSelectedRow(parameters)
this.sampleWindow = null
if (index == 0) {
createHighestConcentrationWaypoint()
stopSession()
SuiMessageBox().run {
title = "@survey:cnode_t"
prompt = "@survey:cnode_d"
setProperty("btnOk", "Text", "@survey:cnode_2")
setProperty("btnCancel", "Text", "@survey:cnode_1")
addOkButtonCallback("okButton") { _: SuiEvent, parameters: Map<String, String> ->
val index = SuiListBox.getSelectedRow(parameters)
sampleWindow = null
if (index == 0) {
createHighestConcentrationWaypoint()
stopSession()
}
}
addCancelButtonCallback("cancelButton") { _, _ -> sampleWindow = null }

if (sampleWindow == null) {
val player = creature.owner ?: return@run
sampleWindow = this@run
display(player)
}
}
window.addCancelButtonCallback("cancelButton") { _: SuiEvent?, _: Map<String?, String?>? -> this.sampleWindow = null }
if (this.sampleWindow == null) {
this.sampleWindow = window
window.display(creature.owner)
}
paused = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class TravelHelper {
return travel[template]
}

fun getAvailableTravelPoints(traveller: SWGObject, terrain: Terrain): List<TravelPoint> {
fun getAvailableTravelPoints(traveller: SWGObject, terrain: Terrain): MutableList<TravelPoint> {
if (!isValidRoute(traveller.terrain, terrain)) return ArrayList()
val nearest = getNearestTravelPoint(traveller)
return pointContainer.getPointsForTerrain(nearest, terrain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TravelPointContainer {
getTravelPoints(terrain, point.isStarport).add(point)
}

fun getPointsForTerrain(nearest: TravelPoint?, to: Terrain): List<TravelPoint> {
fun getPointsForTerrain(nearest: TravelPoint?, to: Terrain): MutableList<TravelPoint> {
val points: MutableList<TravelPoint> = ArrayList()
if (nearest!!.location.terrain == to) {
points.addAll(getTravelPoints(to, false))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/***********************************************************************************
* Copyright (c) 2024 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/
package com.projectswg.holocore.resources.support.data.server_info.loader

import com.projectswg.common.data.combat.*
Expand Down Expand Up @@ -112,8 +138,8 @@ class CombatCommandLoader internal constructor() : DataLoader() {
}

companion object {
private fun getAnimationList(cell: String): Array<String?> {
if (cell.isEmpty()) return arrayOfNulls(0)
private fun getAnimationList(cell: String): Array<String> {
if (cell.isEmpty()) return Array(0) { "" }
return cell.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
}
}
Expand Down
Loading

0 comments on commit 90fe904

Please sign in to comment.