-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Porting on platforms where javafx or awt is not the best choice (e.g. android) is easier
- Loading branch information
Showing
14 changed files
with
121 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/de/bixilon/minosoft/util/system/DesktopAPI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Minosoft | ||
* Copyright (C) 2020-2023 Moritz Zwerger | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* This software is not affiliated with Mojang AB, the original developer of Minecraft. | ||
*/ | ||
|
||
package de.bixilon.minosoft.util.system | ||
|
||
import de.bixilon.minosoft.assets.IntegratedAssets | ||
import java.awt.Taskbar | ||
import java.awt.Toolkit | ||
import java.io.File | ||
import java.net.URL | ||
|
||
open class DesktopAPI : SystemAPI { | ||
|
||
init { | ||
setTaskbarIcon() | ||
} | ||
|
||
override fun openFile(file: File) = Unit | ||
override fun openURL(url: URL) = Unit | ||
|
||
private fun Taskbar.setDockIcon() { | ||
iconImage = Toolkit.getDefaultToolkit().createImage(IntegratedAssets.DEFAULT[SystemUtil.ICON].readAllBytes()) | ||
} | ||
|
||
private fun Taskbar.initialize() { | ||
if (isSupported(Taskbar.Feature.ICON_IMAGE)) { | ||
setDockIcon() | ||
} | ||
} | ||
|
||
private fun setTaskbarIcon() { | ||
System.setProperty("java.awt.headless", false.toString()) | ||
if (Taskbar.isTaskbarSupported()) { | ||
Taskbar.getTaskbar().initialize() | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/de/bixilon/minosoft/util/system/SystemAPI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Minosoft | ||
* Copyright (C) 2020-2023 Moritz Zwerger | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* This software is not affiliated with Mojang AB, the original developer of Minecraft. | ||
*/ | ||
|
||
package de.bixilon.minosoft.util.system | ||
|
||
import java.io.File | ||
import java.net.URL | ||
|
||
interface SystemAPI { | ||
|
||
fun openURL(url: URL) | ||
fun openFile(file: File) | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/de/bixilon/minosoft/util/system/SystemUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Minosoft | ||
* Copyright (C) 2020-2023 Moritz Zwerger | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* This software is not affiliated with Mojang AB, the original developer of Minecraft. | ||
*/ | ||
|
||
package de.bixilon.minosoft.util.system | ||
|
||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft | ||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture | ||
|
||
|
||
object SystemUtil { | ||
val ICON = minosoft("icons/window_icon").texture() | ||
var api: SystemAPI? = null | ||
} |