├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── kotlinc.xml
├── misc.xml
├── modules
│ ├── smblevelworkshop.iml
│ ├── lib
│ │ ├── FluidUI
│ │ │ ├── FluidUI.iml
│ │ │ ├── FluidUI_main.iml
│ │ │ └── FluidUI_test.iml
│ │ └── SMBWorkshopExporter
│ │ │ ├── SMBWorkshopExporter.iml
│ │ │ ├── SMBWorkshopExporter_main.iml
│ │ │ └── SMBWorkshopExporter_test.iml
│ ├── smblevelworkshop_main.iml
│ └── smblevelworkshop_test.iml
├── compiler.xml
└── modules.xml
├── screenshots
├── 01.png
└── 02.png
├── lib
└── libfixXInitThreads.so
├── src
└── main
│ ├── resources
│ ├── icon16.png
│ ├── icon32.png
│ ├── icon128.png
│ ├── Roboto-Regular.ttf
│ ├── resources
│ │ └── vanilla
│ │ │ ├── shader
│ │ │ ├── colUnlitVert.vert
│ │ │ ├── colUnlitFrag.frag
│ │ │ ├── texUnlitVert.vert
│ │ │ ├── texUnlitFrag.frag
│ │ │ ├── shaderCache.shaders.json
│ │ │ ├── colVert.vert
│ │ │ ├── texVert.vert
│ │ │ ├── colFrag.frag
│ │ │ └── texFrag.frag
│ │ │ ├── font
│ │ │ └── fontCache.fonts.json
│ │ │ ├── image
│ │ │ ├── close.png
│ │ │ ├── lock.png
│ │ │ ├── pause.png
│ │ │ ├── play.png
│ │ │ ├── toEnd.png
│ │ │ ├── arrowUp.png
│ │ │ ├── circle.png
│ │ │ ├── rename.png
│ │ │ ├── rewind.png
│ │ │ ├── rotate.png
│ │ │ ├── toStart.png
│ │ │ ├── arrowAll.png
│ │ │ ├── arrowDown.png
│ │ │ ├── arrowLeft.png
│ │ │ ├── arrowRight.png
│ │ │ ├── fastRewind.png
│ │ │ ├── keyframe.png
│ │ │ ├── visibility.png
│ │ │ ├── arrowLeftUp.png
│ │ │ ├── checkBoxTick.png
│ │ │ ├── fastForward.png
│ │ │ ├── arrowRightDown.png
│ │ │ ├── modeEditCursor.png
│ │ │ ├── visibilityOff.png
│ │ │ └── keyframeSelected.png
│ │ │ ├── _loadBackground.png
│ │ │ └── model
│ │ │ ├── WormBlack.exclude.png
│ │ │ ├── WormWood.exclude.png
│ │ │ ├── WormSurface.exclude.png
│ │ │ ├── falloutGrid.exclude.png
│ │ │ ├── monkeyBall.mtl
│ │ │ ├── falloutVolume.mtl
│ │ │ ├── falloutPlane.mtl
│ │ │ ├── GOAL.mtl
│ │ │ ├── falloutPlane.obj
│ │ │ ├── wormhole.mtl
│ │ │ └── falloutVolume.obj
│ ├── log4j2.xml
│ └── initResources.properties
│ └── java
│ ├── craftedcart
│ └── smblevelworkshop
│ │ ├── resource
│ │ ├── IResource.java
│ │ ├── model
│ │ │ ├── OBJFacesByMaterial.java
│ │ │ ├── OBJObject.java
│ │ │ ├── ResourceModel.java
│ │ │ └── OBJScene.java
│ │ ├── ResourceShaderProgram.java
│ │ ├── ResourceTexture.java
│ │ ├── ResourceShader.java
│ │ └── LangManager.java
│ │ ├── util
│ │ ├── EnumAxis.java
│ │ ├── EnumObjectMode.java
│ │ ├── EnumActionMode.java
│ │ ├── DepthSortedPlaceable.java
│ │ ├── DepthComparator.java
│ │ ├── QuickMapEntry.java
│ │ ├── ITransformable.java
│ │ ├── Vec3f.java
│ │ ├── PosXYZ.java
│ │ ├── MathUtils.java
│ │ ├── LogHelper.java
│ │ └── WSItemGroup.java
│ │ ├── exception
│ │ └── GLSLCompileException.java
│ │ ├── asset
│ │ ├── AssetManager.java
│ │ ├── AssetBumper.java
│ │ ├── AssetJamabar.java
│ │ ├── AssetFalloutVolume.java
│ │ ├── AssetStartPos.java
│ │ ├── AssetFalloutY.java
│ │ ├── AssetWormhole.java
│ │ ├── IAsset.java
│ │ ├── AssetGoal.java
│ │ ├── AssetBanana.java
│ │ └── Placeable.java
│ │ ├── ui
│ │ ├── DialogUITheme.java
│ │ ├── DefaultUITheme.java
│ │ ├── NotificationPlugin.java
│ │ ├── TypeSelectorOverlayScreen.java
│ │ ├── component
│ │ │ ├── transform
│ │ │ │ ├── ScaleTextFields.java
│ │ │ │ ├── PositionTextFields.java
│ │ │ │ ├── PlaceableScaleTextFields.java
│ │ │ │ ├── PlaceablePositionTextFields.java
│ │ │ │ ├── PlaceableRotationTextFields.java
│ │ │ │ ├── RotationTextFields.java
│ │ │ │ └── XYZKeyframeButtons.java
│ │ │ ├── FPSOverlay.java
│ │ │ ├── timeline
│ │ │ │ └── TimelinePlayhead.java
│ │ │ ├── ItemButton.java
│ │ │ ├── KeyDisplay.java
│ │ │ ├── InputOverlay.java
│ │ │ └── OutlinerObject.java
│ │ ├── DialogOverlayUIScreen.java
│ │ ├── ItemGroupSelectorOverlayScreen.java
│ │ └── ColorPickerOverlayUIScreen.java
│ │ ├── Project.java
│ │ ├── animation
│ │ ├── KeyframeEntry.java
│ │ ├── NamedTransform.java
│ │ └── BufferedAnimData.java
│ │ ├── undo
│ │ ├── UndoCommand.java
│ │ ├── UndoAssetTransform.java
│ │ ├── UndoAssetTypeChange.java
│ │ ├── UndoObjectItemGroupChange.java
│ │ ├── UndoPlaceableItemGroupChange.java
│ │ ├── UndoAddPlaceable.java
│ │ └── UndoRemovePlaceable.java
│ │ ├── project
│ │ └── ProjectManager.java
│ │ ├── SMBLWSettings.java
│ │ └── SMBLevelWorkshop.java
│ └── com
│ └── owens
│ └── oobjloader
│ ├── builder
│ ├── ReflectivityTransmiss.java
│ ├── FaceVertex.java
│ ├── VertexTexture.java
│ ├── VertexGeometric.java
│ ├── VertexNormal.java
│ ├── Material.java
│ └── Face.java
│ ├── lwjgl
│ ├── DisplayModel.java
│ └── TextureLoader.java
│ └── parser
│ └── BuilderInterface.java
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitmodules
├── settings.gradle
├── README.md
├── gradlew.bat
└── .gitignore
/.idea/.name:
--------------------------------------------------------------------------------
1 | smblevelworkshop
--------------------------------------------------------------------------------
/screenshots/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/screenshots/01.png
--------------------------------------------------------------------------------
/screenshots/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/screenshots/02.png
--------------------------------------------------------------------------------
/lib/libfixXInitThreads.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/lib/libfixXInitThreads.so
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/main/resources/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/icon16.png
--------------------------------------------------------------------------------
/src/main/resources/icon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/icon32.png
--------------------------------------------------------------------------------
/src/main/resources/icon128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/icon128.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/main/resources/Roboto-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/Roboto-Regular.ttf
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/colUnlitVert.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | void main()
4 | {
5 | gl_Position = ftransform();
6 | }
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/colUnlitFrag.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | void main()
4 | {
5 | gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
6 | }
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/font/fontCache.fonts.json:
--------------------------------------------------------------------------------
1 | [
2 | {"name": "Roboto-Regular", "size": 48},
3 | {"name": "Roboto-Regular", "size": 12}
4 | ]
5 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/close.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/lock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/lock.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/pause.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/play.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/toEnd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/toEnd.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowUp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowUp.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/circle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/circle.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/rename.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/rename.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/rewind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/rewind.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/rotate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/rotate.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/toStart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/toStart.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/_loadBackground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/_loadBackground.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowAll.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowAll.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowDown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowDown.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowLeft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowLeft.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowRight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowRight.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/fastRewind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/fastRewind.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/keyframe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/keyframe.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/visibility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/visibility.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowLeftUp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowLeftUp.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/checkBoxTick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/checkBoxTick.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/fastForward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/fastForward.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/arrowRightDown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/arrowRightDown.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/modeEditCursor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/modeEditCursor.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/visibilityOff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/visibilityOff.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/image/keyframeSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/image/keyframeSelected.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/WormBlack.exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/model/WormBlack.exclude.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/WormWood.exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/model/WormWood.exclude.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/WormSurface.exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/model/WormSurface.exclude.png
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/falloutGrid.exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CraftedCart/SMBLevelWorkshop/HEAD/src/main/resources/resources/vanilla/model/falloutGrid.exclude.png
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/IResource.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource;
2 |
3 | /**
4 | * Created by CraftedCart on 28/03/2016 (DD/MM/YYYY)
5 | */
6 | public interface IResource {}
7 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/texUnlitVert.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | varying vec2 texture_coordinate;
4 |
5 | void main()
6 | {
7 | gl_Position = ftransform();
8 | texture_coordinate = vec2(gl_MultiTexCoord0);
9 | }
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/texUnlitFrag.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | uniform sampler2D tex;
4 | varying vec2 texture_coordinate;
5 |
6 | void main()
7 | {
8 | gl_FragColor = texture2D(tex, fract(texture_coordinate));
9 | }
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/monkeyBall.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 1
3 |
4 | newmtl None
5 | Ns 0
6 | Ka 0.000000 0.000000 0.000000
7 | Kd 0.8 0.8 0.8
8 | Ks 0.8 0.8 0.8
9 | d 1
10 | illum 2
11 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "lib/FluidUI"]
2 | path = lib/FluidUI
3 | url = https://github.com/CraftedCart/FluidUI.git
4 | [submodule "lib/SMBWorkshopExporter"]
5 | path = lib/SMBWorkshopExporter
6 | url = https://github.com/CraftedCart/SMBWorkshopExporter/
7 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/EnumAxis.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 30/10/2016 (DD/MM/YYYY)
6 | */
7 | public enum EnumAxis {
8 | X,
9 | Y,
10 | Z
11 | }
12 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Sep 06 20:27:40 BST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'smblevelworkshop'
2 |
3 | include ':FluidUI'
4 | project(":FluidUI").projectDir = new File(settingsDir, 'lib/FluidUI')
5 |
6 | include ':SMBWorkshopExporter'
7 | project(":SMBWorkshopExporter").projectDir = new File(settingsDir, 'lib/SMBWorkshopExporter')
8 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/EnumObjectMode.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 11/10/2016 (DD/MM/YYYY)
6 | */
7 | public enum EnumObjectMode {
8 | PLACEABLE_EDIT,
9 | OBJECT_EDIT
10 | }
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/falloutVolume.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 1
3 |
4 | newmtl MatMain
5 | Ns 92.156863
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.800000 0.800000 0.800000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/falloutPlane.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 1
3 |
4 | newmtl FalloutGrid
5 | Ns 94.117647
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.800000 0.800000 0.800000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 | map_Kd falloutGrid.exclude.png
14 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.exception;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 06/04/2016 (DD/MM/YYYY)
6 | */
7 | public class GLSLCompileException extends Exception {
8 |
9 | public GLSLCompileException(String message) {
10 | super("\n" + message);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/shaderCache.shaders.json:
--------------------------------------------------------------------------------
1 | [
2 | {"name": "texShaderProgram", "vert": "shader/texVert", "frag": "shader/texFrag"},
3 | {"name": "texUnlitShaderProgram", "vert": "shader/texUnlitVert", "frag": "shader/texUnlitFrag"},
4 | {"name": "colShaderProgram", "vert": "shader/colVert", "frag": "shader/colFrag"},
5 | {"name": "colUnlitShaderProgram", "vert": "shader/colUnlitVert", "frag": "shader/colUnlitFrag"}
6 | ]
--------------------------------------------------------------------------------
/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/EnumActionMode.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 08/09/2016 (DD/MM/YYYY)
6 | */
7 | public enum EnumActionMode {
8 | NONE,
9 | GRAB_PLACEABLE,
10 | ROTATE_PLACEABLE,
11 | SCALE_PLACEABLE,
12 | GRAB_KEYFRAME,
13 | SCALE_KEYFRAME;
14 |
15 | public boolean isPlaceableMode() {
16 | int pos = ordinal();
17 | return pos == 1 || pos == 2 || pos == 3;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/colVert.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 | varying vec3 position;
3 | varying vec3 normal;
4 |
5 | varying vec4 color;
6 |
7 | void main()
8 | {
9 | gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex; //output position with projection
10 | position=vec3(gl_ModelViewMatrix*gl_Vertex); //get the position of the vertex after translation, rotation, scaling
11 | normal=gl_NormalMatrix*gl_Normal; //get the normal direction, after translation, rotation, scaling
12 | color = gl_Color;
13 | }
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/texVert.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 | varying vec3 position;
3 | varying vec3 normal;
4 |
5 | varying vec2 texture_coordinate;
6 |
7 | void main()
8 | {
9 | gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex; //output position with projection
10 | position=vec3(gl_ModelViewMatrix*gl_Vertex); //get the position of the vertex after translation, rotation, scaling
11 | normal=gl_NormalMatrix*gl_Normal; //get the normal direction, after translation, rotation, scaling
12 | texture_coordinate = vec2(gl_MultiTexCoord0);
13 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/DepthSortedPlaceable.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 |
5 | import java.util.Map;
6 |
7 | /**
8 | * @author CraftedCart
9 | * Created on 25/09/2016 (DD/MM/YYYY)
10 | */
11 | public class DepthSortedPlaceable {
12 | public double depth;
13 | public Map.Entry entry;
14 |
15 | public DepthSortedPlaceable(double depth, Map.Entry entry) {
16 | this.depth = depth;
17 | this.entry = entry;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetManager.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 10/09/2016 (DD/MM/YYYY)
6 | */
7 | public class AssetManager {
8 |
9 | private static final IAsset[] avaliableAssets = new IAsset[]{
10 | new AssetBanana(),
11 | new AssetBumper(),
12 | new AssetGoal(),
13 | new AssetJamabar(),
14 | new AssetWormhole(),
15 | new AssetFalloutVolume()
16 | };
17 |
18 | public static IAsset[] getAvaliableAssets() {
19 | return avaliableAssets;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/DepthComparator.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | import java.util.Comparator;
4 |
5 | /**
6 | * @author CraftedCart
7 | * Created on 25/09/2016 (DD/MM/YYYY)
8 | */
9 | public class DepthComparator implements Comparator {
10 |
11 | @Override
12 | public int compare(DepthSortedPlaceable o1, DepthSortedPlaceable o2) {
13 | if (o1.depth < o2.depth) {
14 | return 1;
15 | } else if (o1.depth > o2.depth) {
16 | return -1;
17 | } else {
18 | return 0;
19 | }
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/DialogUITheme.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import io.github.craftedcart.fluidui.FontCache;
4 | import io.github.craftedcart.fluidui.theme.UITheme;
5 | import io.github.craftedcart.fluidui.util.UIColor;
6 |
7 | /**
8 | * @author CraftedCart
9 | * Created on 05/03/2016 (DD/MM/YYYY)
10 | */
11 | public class DialogUITheme extends UITheme {
12 |
13 | public DialogUITheme() {
14 | panelBackgroundColor = UIColor.matWhite();
15 | labelFont = FontCache.getUnicodeFont("Roboto-Regular", 16);
16 | labelTextColor = UIColor.matGrey900();
17 | scrollbarThickness = 2;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/Project.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop;
2 |
3 | import craftedcart.smblevelworkshop.level.ClientLevelData;
4 | import craftedcart.smblevelworkshop.util.EnumActionMode;
5 | import craftedcart.smblevelworkshop.util.PosXYZ;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 04/10/2016 (DD/MM/YYYY)
12 | */
13 | public class Project {
14 |
15 | @Nullable public ClientLevelData clientLevelData;
16 | @NotNull public EnumActionMode mode = EnumActionMode.NONE;
17 | @NotNull public PosXYZ modeDirection = new PosXYZ(0, 1, 0);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/model/OBJFacesByMaterial.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource.model;
2 |
3 | import com.owens.oobjloader.builder.Face;
4 | import com.owens.oobjloader.lwjgl.VBO;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/10/2016 (DD/MM/YYYY)
12 | */
13 | public class OBJFacesByMaterial {
14 |
15 | public List faceList = new ArrayList<>();
16 | public VBO vbo;
17 |
18 | public void setFaceList(List faceList) {
19 | this.faceList = faceList;
20 | }
21 |
22 | public void setVbo(VBO vbo) {
23 | this.vbo = vbo;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/animation/KeyframeEntry.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.animation;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 01/01/2017 (DD/MM/YYYY)
6 | */
7 | public class KeyframeEntry {
8 |
9 | private String objectName;
10 | private float time;
11 |
12 | public KeyframeEntry(String objectName, float time) {
13 | this.objectName = objectName;
14 | this.time = time;
15 | }
16 |
17 | public String getObjectName() {
18 | return objectName;
19 | }
20 |
21 | public float getTime() {
22 | return time;
23 | }
24 |
25 | public void setTime(float time) {
26 | this.time = time;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/DefaultUITheme.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import io.github.craftedcart.fluidui.FontCache;
4 | import io.github.craftedcart.fluidui.theme.UITheme;
5 | import io.github.craftedcart.fluidui.util.UIColor;
6 |
7 | /**
8 | * @author CraftedCart
9 | * Created on 05/03/2016 (DD/MM/YYYY)
10 | */
11 | public class DefaultUITheme extends UITheme {
12 |
13 | public DefaultUITheme() {
14 | labelFont = FontCache.getUnicodeFont("Roboto-Regular", 16);
15 | headerFont = FontCache.getUnicodeFont("Roboto-Regular", 24);
16 | labelTextColor = UIColor.matWhite();
17 | scrollbarThickness = 2;
18 | checkBoxUncheckedColor = UIColor.matWhite();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/QuickMapEntry.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * @author CraftedCart
7 | * Created on 03/11/2016 (DD/MM/YYYY)
8 | */
9 | public class QuickMapEntry implements Map.Entry {
10 |
11 | private K key;
12 | private V value;
13 |
14 | public QuickMapEntry(K key, V value) {
15 | this.key = key;
16 | this.value = value;
17 | }
18 |
19 | @Override
20 | public K getKey() {
21 | return key;
22 | }
23 |
24 | @Override
25 | public V getValue() {
26 | return value;
27 | }
28 |
29 | @Override
30 | public V setValue(V value) {
31 | return null;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/GOAL.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 3
3 |
4 | newmtl MatMain
5 | Ns 94.117647
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.800000 0.800000 0.800000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 |
14 | newmtl MatSemiTransparent
15 | Ns 94.117647
16 | Ka 1.000000 1.000000 1.000000
17 | Kd 0.800000 0.800000 0.800000
18 | Ks 0.500000 0.500000 0.500000
19 | Ke 0.000000 0.000000 0.000000
20 | Ni 1.000000
21 | d 0.250000
22 | illum 2
23 |
24 | newmtl None
25 | Ns 0.000000
26 | Ka 0.000000 0.000000 0.000000
27 | Kd 0.800000 0.800000 0.800000
28 | Ks 0.800000 0.800000 0.800000
29 | Ke 0.000000 0.000000 0.000000
30 | Ni 1.000000
31 | d 1.000000
32 | illum 2
33 |
--------------------------------------------------------------------------------
/.idea/modules/smblevelworkshop.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/modules/lib/FluidUI/FluidUI.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/falloutPlane.obj:
--------------------------------------------------------------------------------
1 | # Blender v2.78 (sub 0) OBJ File: ''
2 | # www.blender.org
3 | mtllib falloutPlane.mtl
4 | o Plane
5 | v 1000.000000 -0.000163 1000.000000
6 | v -1000.000000 0.000163 -1000.000000
7 | v -1000.000000 -0.000163 1000.000000
8 | v 1000.000000 0.000163 -1000.000000
9 | v 1000.000000 -0.000163 1000.000000
10 | v -1000.000000 0.000163 -1000.000000
11 | v -1000.000000 -0.000163 1000.000000
12 | v 1000.000000 0.000163 -1000.000000
13 | vt 1000.8002 -998.8002
14 | vt -998.8002 1000.8002
15 | vt -998.8000 -998.8002
16 | vt 1000.8002 1000.8002
17 | vt 1000.8002 -998.8002
18 | vt -998.8000 -998.8002
19 | vt -998.8002 1000.8002
20 | vt 1000.8002 1000.8002
21 | vn 0.0000 1.0000 0.0000
22 | vn 0.0000 -1.0000 -0.0000
23 | usemtl FalloutGrid
24 | s 1
25 | f 1/1/1 2/2/1 3/3/1
26 | f 1/1/1 4/4/1 2/2/1
27 | f 5/5/2 7/6/2 6/7/2
28 | f 5/5/2 6/7/2 8/8/2
29 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoCommand.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.level.ClientLevelData;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.jetbrains.annotations.Nullable;
6 |
7 | /**
8 | * @author CraftedCart
9 | * Created on 11/09/2016 (DD/MM/YYYY)
10 | */
11 | public abstract class UndoCommand {
12 |
13 | @NotNull protected ClientLevelData clientLevelData;
14 |
15 | public UndoCommand(@NotNull ClientLevelData clientLevelData) {
16 | this.clientLevelData = clientLevelData;
17 | }
18 |
19 | public abstract void undo();
20 |
21 | /**
22 | * Called before undoing
23 | */
24 | public abstract UndoCommand getRedoCommand();
25 |
26 | @Nullable public abstract String getUndoMessage();
27 | @Nullable public abstract String getRedoMessage();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/.idea/modules/lib/SMBWorkshopExporter/SMBWorkshopExporter.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/model/OBJObject.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource.model;
2 |
3 | import craftedcart.smblevelworkshop.util.Vec3f;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @author CraftedCart
10 | * Created on 10/10/2016 (DD/MM/YYYY)
11 | */
12 | public class OBJObject {
13 |
14 | public String name;
15 | public List facesByMaterialList = new ArrayList<>();
16 | private Vec3f centerPoint;
17 |
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 |
22 | public void addFacesByMaterial(OBJFacesByMaterial mat) {
23 | facesByMaterialList.add(mat);
24 | }
25 |
26 | public void setCenterPoint(Vec3f centerPoint) {
27 | this.centerPoint = centerPoint;
28 | }
29 |
30 | public Vec3f getCenterPoint() {
31 | return centerPoint;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/ReflectivityTransmiss.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | public class ReflectivityTransmiss {
13 |
14 | public boolean isRGB = false;
15 | public boolean isXYZ = false;
16 | public double rx;
17 | public double gy;
18 | public double bz;
19 |
20 | public ReflectivityTransmiss() {
21 | }
22 | }
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/FaceVertex.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | public class FaceVertex {
13 |
14 | int index = -1;
15 | public VertexGeometric v = null;
16 | public VertexTexture t = null;
17 | public VertexNormal n = null;
18 |
19 | public String toString() {
20 | return v + "|" + n + "|" + t;
21 | }
22 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/project/ProjectManager.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.project;
2 |
3 | import craftedcart.smblevelworkshop.Project;
4 | import craftedcart.smblevelworkshop.level.ClientLevelData;
5 | import craftedcart.smblevelworkshop.level.LevelData;
6 |
7 | /**
8 | * @author CraftedCart
9 | * Created on 04/10/2016 (DD/MM/YYYY)
10 | */
11 | public class ProjectManager {
12 |
13 | private static Project currentProject;
14 |
15 | public static void setCurrentProject(Project currentProject) {
16 | ProjectManager.currentProject = currentProject;
17 | }
18 |
19 | public static Project getCurrentProject() {
20 | return currentProject;
21 | }
22 |
23 | public static LevelData getCurrentLevelData() {
24 | return getCurrentProject().clientLevelData.getLevelData();
25 | }
26 |
27 | public static ClientLevelData getCurrentClientLevelData() {
28 | return getCurrentProject().clientLevelData;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 01/11/2016 (DD/MM/YYYY)
6 | */
7 | public interface ITransformable {
8 |
9 | default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); }
10 | default PosXYZ getPosition() { throw new UnsupportedOperationException(); }
11 |
12 | default boolean canMoveX() { return true; }
13 | default boolean canMoveY() { return true; }
14 | default boolean canMoveZ() { return true; }
15 |
16 | default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); }
17 | default PosXYZ getRotation() { throw new UnsupportedOperationException(); }
18 |
19 | default boolean canRotate() { return true; }
20 |
21 | default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); }
22 | default PosXYZ getScale() { throw new UnsupportedOperationException(); }
23 |
24 | default boolean canScale() { return true; }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/VertexTexture.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | public class VertexTexture {
13 |
14 | public float u = 0;
15 | public float v = 0;
16 |
17 | VertexTexture(float u, float v) {
18 | this.u = u;
19 | this.v = v;
20 | }
21 |
22 | public String toString() {
23 | if (null == this) {
24 | return "null";
25 | } else {
26 | return u + "," + v;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource;
2 |
3 | import craftedcart.smblevelworkshop.Window;
4 | import org.lwjgl.opengl.GL20;
5 |
6 | /**
7 | * @author CraftedCart
8 | * Created on 06/04/2016 (DD/MM/YYYY)
9 | */
10 | public class ResourceShaderProgram implements IResource {
11 |
12 | private int programID;
13 |
14 | public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception {
15 | Window.drawable.makeCurrent();
16 |
17 | try {
18 | programID = GL20.glCreateProgram();
19 | GL20.glAttachShader(programID, vertShader.getShaderID());
20 | GL20.glAttachShader(programID, fragShader.getShaderID());
21 | GL20.glLinkProgram(programID);
22 | GL20.glValidateProgram(programID);
23 | } catch (NullPointerException e) {
24 | throw new Exception(e);
25 | }
26 |
27 | Window.drawable.releaseContext();
28 | }
29 |
30 | public int getProgramID() {
31 | return programID;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/animation/NamedTransform.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.animation;
2 |
3 | import craftedcart.smblevelworkshop.util.ITransformable;
4 | import craftedcart.smblevelworkshop.util.PosXYZ;
5 |
6 | /**
7 | * @author CraftedCart
8 | * Created on 03/11/2016 (DD/MM/YYYY)
9 | */
10 | public class NamedTransform implements ITransformable {
11 |
12 | private String name;
13 | private PosXYZ position = new PosXYZ();
14 | private PosXYZ rotation = new PosXYZ();
15 |
16 | public NamedTransform(String name) {
17 | this.name = name;
18 | }
19 |
20 | @Override
21 | public void setPosition(PosXYZ position) {
22 | this.position = position;
23 | }
24 |
25 | @Override
26 | public PosXYZ getPosition() {
27 | return position;
28 | }
29 |
30 | @Override
31 | public void setRotation(PosXYZ rotation) {
32 | this.rotation = rotation;
33 | }
34 |
35 | @Override
36 | public PosXYZ getRotation() {
37 | return rotation;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/VertexGeometric.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | public class VertexGeometric {
13 |
14 | public float x = 0;
15 | public float y = 0;
16 | public float z = 0;
17 |
18 | public VertexGeometric(float x, float y, float z) {
19 | this.x = x;
20 | this.y = y;
21 | this.z = z;
22 | }
23 |
24 | public String toString() {
25 | if (null == this) {
26 | return "null";
27 | } else {
28 | return x + "," + y + "," + z;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/VertexNormal.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | public class VertexNormal {
13 | public float x = 0;
14 | public float y = 0;
15 | public float z = 0;
16 |
17 | public void add(float x, float y, float z) {
18 | this.x += x;
19 | this.y += y;
20 | this.z += z;
21 | }
22 |
23 | public VertexNormal(float x, float y, float z) {
24 | this.x = x;
25 | this.y = y;
26 | this.z = z;
27 | }
28 |
29 | public String toString() {
30 | if(null == this)
31 | return "null";
32 | else
33 | return x+","+y+","+z;
34 | }
35 | }
--------------------------------------------------------------------------------
/src/main/resources/initResources.properties:
--------------------------------------------------------------------------------
1 | smbLevelWorkshop=SMB Level Workshop
2 | loadingResources=Loading Resources...
3 |
4 | unrecognisedFileExtension=Unrecognised resource file extension
5 |
6 | #Font cache errors
7 | errorFontSizeNotNumber=Invalid fonts definition - Entry "size" of %s is not a number
8 | errorFontNameNotString=Invalid fonts definition - Entry "name" of %s is not a string
9 | errorFontDefMissingKeys=Invalid fonts definition - Entry "%s" does not contain the keys "name" and "size"
10 | errorFontDefNotArray=Invalid fonts definition - File contents is not an array
11 |
12 | #Lang errors
13 | errorLangNoLocale=No locale attribute specified on the root tag
14 | errorLangNotLangPack=The root tag is not "langPack"
15 | errorLangMissingKeyVal=XML node entry missing attributes "key" and "val"
16 |
17 | #Shader program cache errors
18 | errorShaderProgDefNotArray=Invalid shader programs definition - File contents is not an array
19 | errorShaderProgDefMissingKeys=Invalid shader program definition - Entry "%s" does not contain the keys "name", "vert" and "frag"
20 | errorShaderProgEntriesNotString=Invalid shader program definition - Entry "name", "vert" and / or "frag" of "%s" is not a string
21 |
22 | #Crashed
23 | crashed=Crashed
24 | quit=Quit
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SMBLevelWorkshop
2 | A Super Monkey Ball Level Editor
3 |
4 | 
5 | 
6 |
7 | ### Building from Source
8 | First, make sure you have JDK 8 or higher installed, Git, as well as Gradle (Or just use the bundled Gradle by using `./gradlew` on Unix like systems, or `gradlew.bat` on Windows)
9 |
10 | ##### Cloning this Repository
11 | ```shell
12 | git clone https://github.com/CraftedCart/SMBLevelWorkshop.git
13 | cd SMBLevelWorkshop
14 | git submodule update --init --recursive
15 | ```
16 | ##### Creating a JAR file
17 | ```shell
18 | gradle jar
19 | ```
20 |
21 | ##### Getting LWJGL natives
22 | ```shell
23 | gradle natives
24 | ```
25 |
26 | ##### Copying natives over
27 | ###### Windows *(Note: I don't know Windows commands - Just do it in Explorer)*
28 | Copy everything in `build\natives-windows` to `build\libs`
29 |
30 | ###### OS X / macOS
31 | ```shell
32 | cp -r build/natives-osx/* build/libs
33 | ```
34 |
35 | ###### Linux
36 | ```shell
37 | cp -r build/natives-linux/* build/libs
38 | cp lib/libfixXInitThreads.so build/libs #Don't forget this!
39 | ```
40 |
41 | ##### Running SMB Level Workshop
42 | ```shell
43 | cd build/libs
44 | java -Djava.library.path=. -jar smblevelworkshop-1.0-SNAPSHOT.jar
45 | ```
46 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetBumper.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
5 | import craftedcart.smblevelworkshop.util.LogHelper;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class AssetBumper implements IAsset {
14 |
15 | @NotNull
16 | @Override
17 | public String getName() {
18 | return "assetBumper";
19 | }
20 |
21 | @NotNull
22 | @Override
23 | public ResourceModel getModel() {
24 | return ResourceManager.getModel("model/mb_bumper");
25 | }
26 |
27 | @NotNull
28 | @Override
29 | public UIColor getColor() {
30 | return UIColor.matOrange();
31 | }
32 |
33 | @Override
34 | public IAsset getCopy() {
35 | try {
36 | return (IAsset) clone();
37 | } catch (CloneNotSupportedException e) {
38 | LogHelper.error(getClass(), "Failed to clone IAsset");
39 | LogHelper.error(getClass(), e);
40 | return null;
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetJamabar.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
5 | import craftedcart.smblevelworkshop.util.LogHelper;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class AssetJamabar implements IAsset {
14 |
15 | @NotNull
16 | @Override
17 | public String getName() {
18 | return "assetJamabar";
19 | }
20 |
21 | @NotNull
22 | @Override
23 | public ResourceModel getModel() {
24 | return ResourceManager.getModel("model/mb_jamabar");
25 | }
26 |
27 | @NotNull
28 | @Override
29 | public UIColor getColor() {
30 | return UIColor.matRed();
31 | }
32 |
33 | @Override
34 | public IAsset getCopy() {
35 | try {
36 | return (IAsset) clone();
37 | } catch (CloneNotSupportedException e) {
38 | LogHelper.error(getClass(), "Failed to clone IAsset");
39 | LogHelper.error(getClass(), e);
40 | return null;
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/ResourceTexture.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource;
2 |
3 | import craftedcart.smblevelworkshop.Window;
4 | import org.lwjgl.opengl.GL11;
5 | import org.newdawn.slick.opengl.Texture;
6 | import org.newdawn.slick.opengl.TextureLoader;
7 |
8 | import java.io.File;
9 | import java.io.FileInputStream;
10 |
11 | /**
12 | * @author CraftedCart
13 | * Created on 28/03/2016 (DD/MM/YYYY)
14 | */
15 | public class ResourceTexture implements IResource {
16 |
17 | private Texture texture;
18 |
19 | public ResourceTexture(String type, File file) throws Exception {
20 | Window.drawable.makeCurrent();
21 | GL11.glFinish();
22 | FileInputStream fis = new FileInputStream(file);
23 | try {
24 | texture = TextureLoader.getTexture(type, fis);
25 | } catch (Exception e) {
26 | throw new Exception(e);
27 | }
28 | fis.close();
29 | GL11.glFlush();
30 | Window.drawable.releaseContext();
31 | }
32 |
33 | public Texture getTexture() {
34 | return texture;
35 | }
36 |
37 | public int getWidth() {
38 | return texture.getImageWidth();
39 | }
40 |
41 | public int getHeight() {
42 | return texture.getImageHeight();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetFalloutVolume.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
5 | import craftedcart.smblevelworkshop.util.LogHelper;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class AssetFalloutVolume implements IAsset {
14 |
15 | @NotNull
16 | @Override
17 | public String getName() {
18 | return "assetFalloutVolume";
19 | }
20 |
21 | @NotNull
22 | @Override
23 | public ResourceModel getModel() {
24 | return ResourceManager.getModel("model/falloutVolume");
25 | }
26 |
27 | @NotNull
28 | @Override
29 | public UIColor getColor() {
30 | return UIColor.matRed();
31 | }
32 |
33 | @Override
34 | public IAsset getCopy() {
35 | try {
36 | return (IAsset) clone();
37 | } catch (CloneNotSupportedException e) {
38 | LogHelper.error(getClass(), "Failed to clone IAsset");
39 | LogHelper.error(getClass(), e);
40 | return null;
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetStartPos.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
5 | import craftedcart.smblevelworkshop.util.LogHelper;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class AssetStartPos implements IAsset {
14 |
15 | @NotNull
16 | @Override
17 | public String getName() {
18 | return "assetStartPos";
19 | }
20 |
21 | @NotNull
22 | @Override
23 | public ResourceModel getModel() {
24 | return ResourceManager.getModel("model/monkeyBall");
25 | }
26 |
27 | @NotNull
28 | @Override
29 | public UIColor getColor() {
30 | return UIColor.matBlue();
31 | }
32 |
33 | @Override
34 | public boolean canScale() {
35 | return false;
36 | }
37 |
38 | @Override
39 | public IAsset getCopy() {
40 | try {
41 | return (IAsset) clone();
42 | } catch (CloneNotSupportedException e) {
43 | LogHelper.error(getClass(), "Failed to clone IAsset");
44 | LogHelper.error(getClass(), e);
45 | return null;
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/colFrag.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 | varying vec3 position;
3 | varying vec3 normal;
4 |
5 | varying vec4 color;
6 |
7 | uniform vec3 lightPos = vec3(10000, 15000, 5000);
8 |
9 | uniform vec3 mambient = vec3(0.7, 0.7, 0.7); //gl_FrontMaterial
10 | uniform vec3 mdiffuse = vec3(1.3, 1.3, 1.3);
11 | uniform vec3 mspecular = vec3(0.2, 0.2, 0.2);
12 | uniform float shininess = 0.2f;
13 |
14 | uniform vec3 lambient = vec3(0.3, 0.3, 0.3); //gl_LightSource[0]
15 | uniform vec3 ldiffuse = vec3(0.8, 0.8, 0.8);
16 | uniform vec3 lspecular = vec3(0.3, 0.3, 0.3);
17 |
18 |
19 | void main()
20 | {
21 | float dist=length(position-lightPos); //distance from light-source to surface
22 | // float att=1.0/(1.0+0.1*dist+0.01*dist*dist); //attenuation (constant,linear,quadric)
23 | vec3 ambient=mambient*lambient; //the ambient light
24 |
25 | vec3 surf2light=normalize(lightPos-position);
26 | vec3 norm=normalize(normal);
27 | float dcont=max(0.0,dot(norm,surf2light));
28 | vec3 diffuse=dcont*(mdiffuse*ldiffuse);
29 |
30 | vec3 surf2view=normalize(-position);
31 | vec3 reflection=reflect(-surf2light,norm);
32 |
33 | float scont=pow(max(0.0,dot(surf2view,reflection)),shininess);
34 | vec3 specular=scont*lspecular*mspecular;
35 |
36 | gl_FragColor=vec4((ambient+diffuse/*+specular*/)/**att*/,1.0) * color; //<- don't forget the paranthesis (ambient+diffuse+specular)
37 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/NotificationPlugin.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import io.github.craftedcart.fluidui.plugin.AbstractComponentPlugin;
4 | import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor;
5 | import io.github.craftedcart.fluidui.util.UIUtils;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | /**
9 | * @author CraftedCart
10 | * Created on 11/09/2016 (DD/MM/YYYY)
11 | */
12 | public class NotificationPlugin extends AbstractComponentPlugin {
13 |
14 | @NotNull private PluginSmoothAnimateAnchor animateAnchor;
15 |
16 | public double time = 0;
17 |
18 | public NotificationPlugin(@NotNull PluginSmoothAnimateAnchor animateAnchor) {
19 | this.animateAnchor = animateAnchor;
20 | }
21 |
22 | @Override
23 | public void onPostInit() {
24 | animateAnchor.setTargetTopLeftAnchor(0, 1);
25 | animateAnchor.setTargetBottomRightAnchor(1, 1);
26 | }
27 |
28 | @Override
29 | public void onPreDraw() {
30 | time += UIUtils.getDelta();
31 |
32 | if (time >= 5) { //Remove after 5s
33 | assert linkedComponent.parentComponent != null;
34 | linkedComponent.parentComponent.childComponents.remove(linkedComponent.name);
35 | } else if (time >= 1.5) { //Anim out after 1.5s
36 | animateAnchor.setTargetTopLeftAnchor(0, 1.2);
37 | animateAnchor.setTargetBottomRightAnchor(1, 1.2);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/Vec3f.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 07/09/2016 (DD/MM/YYYY)
6 | */
7 | public class Vec3f {
8 |
9 | public float x;
10 | public float y;
11 | public float z;
12 |
13 | public Vec3f() {}
14 |
15 | public Vec3f(float x, float y, float z) {
16 | this.x = x;
17 | this.y = y;
18 | this.z = z;
19 | }
20 |
21 | public Vec3f add(Vec3f pos) {
22 | return new Vec3f(this.x + pos.x, this.y + pos.y, this.z + pos.z);
23 | }
24 |
25 | public Vec3f add(float x, float y, float z) {
26 | return new Vec3f(this.x + x, this.y + y, this.z + z);
27 | }
28 |
29 | public Vec3f subtract(Vec3f pos) {
30 | return new Vec3f(this.x - pos.x, this.y - pos.y, this.z - pos.z);
31 | }
32 |
33 | public Vec3f subtract(float x, float y, float z) {
34 | return new Vec3f(this.x - x, this.y - y, this.z - z);
35 | }
36 |
37 | public Vec3f multiply(float factor) {
38 | return new Vec3f(x * factor, y * factor, z * factor);
39 | }
40 |
41 | @Override
42 | public boolean equals(Object obj) {
43 | if (obj instanceof Vec3f) {
44 | Vec3f posObj = (Vec3f) obj;
45 | return posObj.x == x && posObj.y == y && posObj.z == z;
46 | } else {
47 | return false;
48 | }
49 | }
50 |
51 | public Vec3f getCopy() {
52 | return new Vec3f(x, y, z);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/shader/texFrag.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 | varying vec3 position;
3 | varying vec3 normal;
4 | varying vec2 texture_coordinate;
5 |
6 | uniform sampler2D tex;
7 |
8 | uniform vec3 lightPos = vec3(10000, 15000, 5000);
9 |
10 | uniform vec3 mambient = vec3(0.7, 0.7, 0.7); //gl_FrontMaterial
11 | uniform vec3 mdiffuse = vec3(1.3, 1.3, 1.3);
12 | uniform vec3 mspecular = vec3(0.2, 0.2, 0.2);
13 | uniform float shininess = 0.2f;
14 |
15 | uniform vec3 lambient = vec3(0.3, 0.3, 0.3); //gl_LightSource[0]
16 | uniform vec3 ldiffuse = vec3(0.8, 0.8, 0.8);
17 | uniform vec3 lspecular = vec3(0.3, 0.3, 0.3);
18 |
19 |
20 | void main()
21 | {
22 | float dist=length(position-lightPos); //distance from light-source to surface
23 | // float att=1.0/(1.0+0.1*dist+0.01*dist*dist); //attenuation (constant,linear,quadric)
24 | vec3 ambient=mambient*lambient; //the ambient light
25 |
26 | vec3 surf2light=normalize(lightPos-position);
27 | vec3 norm=normalize(normal);
28 | float dcont=max(0.0,dot(norm,surf2light));
29 | vec3 diffuse=dcont*(mdiffuse*ldiffuse);
30 |
31 | vec3 surf2view=normalize(-position);
32 | vec3 reflection=reflect(-surf2light,norm);
33 |
34 | float scont=pow(max(0.0,dot(surf2view,reflection)),shininess);
35 | vec3 specular=scont*lspecular*mspecular;
36 |
37 | gl_FragColor=vec4((ambient+diffuse/*+specular*/)/**att*/,1.0) * texture2D(tex, fract(texture_coordinate)); //<- don't forget the paranthesis (ambient+diffuse+specular)
38 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/SMBLWSettings.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 10/09/2016 (DD/MM/YYYY)
6 | */
7 | public class SMBLWSettings {
8 |
9 | //Camera
10 | public static double cameraSpeed = 20;
11 | public static double cameraSprintSpeedMultiplier = 5;
12 |
13 | //Sensitivity
14 | public static double modeMouseSensitivity = 0.2;
15 | public static double modeMouseShiftSensitivity = 0.02;
16 | public static double modeMouseWheelSensitivity = 0.001;
17 | public static double modeMouseWheelShiftSensitivity = 0.0001;
18 | public static double modeKeyframeMouseSensitivity = 0.002;
19 | public static double modeKeyframeMouseShiftSensitivity = 0.0002;
20 | public static double modeKeyframeMouseWheelSensitivity = 0.00001;
21 | public static double modeKeyframeMouseWheelShiftSensitivity = 0.000001;
22 |
23 | //Rendering
24 | public static boolean showTextures = true;
25 | public static boolean isUnlit = false;
26 | public static boolean showAllWireframes = false;
27 |
28 | //Snapping
29 | public static double grabSnap = 0.5;
30 | public static double rotationSnap = 5;
31 | public static double scaleSnap = 0.5;
32 | public static float animSnap = 5.0f;
33 | public static float animSnapShift = 0.1f;
34 |
35 | //UI
36 | public static boolean showOnScreenCameraControls = false;
37 | public static boolean showOnScreenInput = false;
38 | public static boolean showFPSOverlay = false;
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/.idea/modules/lib/SMBWorkshopExporter/SMBWorkshopExporter_main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/lwjgl/DisplayModel.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.lwjgl;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | import craftedcart.smblevelworkshop.resource.ResourceShaderProgram;
13 | import io.github.craftedcart.fluidui.util.UIColor;
14 |
15 | import java.util.ArrayList;
16 |
17 | public class DisplayModel {
18 |
19 | public ArrayList vboList = new ArrayList();
20 |
21 | public DisplayModel() {
22 | }
23 |
24 | public void addVBO(VBO r) {
25 | vboList.add(r);
26 | }
27 |
28 | public void render(ResourceShaderProgram shaderProgram, boolean setTexture) {
29 | for (int loopi = 0; loopi < vboList.size(); loopi++) {
30 | vboList.get(loopi).render(shaderProgram, setTexture);
31 | }
32 | }
33 |
34 | public void render(ResourceShaderProgram shaderProgram, boolean setTexture, UIColor color) {
35 | for (int loopi = 0; loopi < vboList.size(); loopi++) {
36 | vboList.get(loopi).render(shaderProgram, setTexture, color);
37 | }
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | /**
4 | * @author CraftedCart
5 | * Created on 07/09/2016 (DD/MM/YYYY)
6 | */
7 | public class PosXYZ {
8 |
9 | public double x;
10 | public double y;
11 | public double z;
12 |
13 | public PosXYZ() {}
14 |
15 | public PosXYZ(double x, double y, double z) {
16 | this.x = x;
17 | this.y = y;
18 | this.z = z;
19 | }
20 |
21 | public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) {
22 | this.x = vec3f.x;
23 | this.y = vec3f.y;
24 | this.z = vec3f.z;
25 | }
26 |
27 | public PosXYZ add(PosXYZ pos) {
28 | return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z);
29 | }
30 |
31 | public PosXYZ add(double x, double y, double z) {
32 | return new PosXYZ(this.x + x, this.y + y, this.z + z);
33 | }
34 |
35 | public PosXYZ subtract(PosXYZ pos) {
36 | return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z);
37 | }
38 |
39 | public PosXYZ subtract(double x, double y, double z) {
40 | return new PosXYZ(this.x - x, this.y - y, this.z - z);
41 | }
42 |
43 | public PosXYZ multiply(double factor) {
44 | return new PosXYZ(x * factor, y * factor, z * factor);
45 | }
46 |
47 | @Override
48 | public boolean equals(Object obj) {
49 | if (obj instanceof PosXYZ) {
50 | PosXYZ posObj = (PosXYZ) obj;
51 | return posObj.x == x && posObj.y == y && posObj.z == z;
52 | } else {
53 | return false;
54 | }
55 | }
56 |
57 | public PosXYZ getCopy() {
58 | return new PosXYZ(x, y, z);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/.idea/modules/lib/SMBWorkshopExporter/SMBWorkshopExporter_test.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetFalloutY.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.ResourceShaderProgram;
5 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
6 | import craftedcart.smblevelworkshop.util.LogHelper;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class AssetFalloutY implements IAsset {
14 |
15 | @NotNull
16 | @Override
17 | public String getName() {
18 | return "assetFalloutY";
19 | }
20 |
21 | @NotNull
22 | @Override
23 | public ResourceModel getModel() {
24 | return ResourceManager.getModel("model/falloutPlane");
25 | }
26 |
27 | @Override
28 | public boolean canGrabX() {
29 | return false;
30 | }
31 |
32 | @Override
33 | public boolean canGrabZ() {
34 | return false;
35 | }
36 |
37 | @Override
38 | public boolean canRotate() {
39 | return false;
40 | }
41 |
42 | @Override
43 | public boolean canScale() {
44 | return false;
45 | }
46 |
47 | @Override
48 | public IAsset getCopy() {
49 | try {
50 | return (IAsset) clone();
51 | } catch (CloneNotSupportedException e) {
52 | LogHelper.error(getClass(), "Failed to clone IAsset");
53 | LogHelper.error(getClass(), e);
54 | return null;
55 | }
56 | }
57 |
58 | @NotNull
59 | @Override
60 | public ResourceShaderProgram getShaderProgram() {
61 | return ResourceManager.getShaderProgram("texUnlitShaderProgram");
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetWormhole.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.ResourceShaderProgram;
5 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
6 | import craftedcart.smblevelworkshop.util.LogHelper;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class AssetWormhole implements IAsset {
14 |
15 | @NotNull private String destinationName = "";
16 |
17 | @NotNull
18 | @Override
19 | public String getName() {
20 | return "assetWormhole";
21 | }
22 |
23 | @NotNull
24 | @Override
25 | public ResourceModel getModel() {
26 | return ResourceManager.getModel("model/wormhole");
27 | }
28 |
29 | @Override
30 | public boolean canScale() {
31 | return false;
32 | }
33 |
34 | @NotNull
35 | public String getDestinationName() {
36 | return destinationName;
37 | }
38 |
39 | public void setDestinationName(@NotNull String destinationName) {
40 | this.destinationName = destinationName;
41 | }
42 |
43 | @NotNull
44 | @Override
45 | public ResourceShaderProgram getShaderProgram() {
46 | return ResourceManager.getShaderProgram("texShaderProgram");
47 | }
48 |
49 | @Override
50 | public IAsset getCopy() {
51 | try {
52 | return (IAsset) clone();
53 | } catch (CloneNotSupportedException e) {
54 | LogHelper.error(getClass(), "Failed to clone IAsset");
55 | LogHelper.error(getClass(), e);
56 | return null;
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoAssetTransform.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.level.ClientLevelData;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 | import java.util.Set;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 11/09/2016 (DD/MM/YYYY)
16 | */
17 | public class UndoAssetTransform extends UndoCommand {
18 |
19 | @NotNull private Map placedObjectsSnapshot = new HashMap<>();
20 |
21 | public UndoAssetTransform(@NotNull ClientLevelData clientLevelData, @NotNull Set selectedPlaceables) {
22 | super(clientLevelData);
23 |
24 | for (String name : selectedPlaceables) {
25 | placedObjectsSnapshot.put(name, clientLevelData.getLevelData().getPlaceable(name).getCopy());
26 | }
27 | }
28 |
29 | @Override
30 | public void undo() {
31 | for (Map.Entry entry : placedObjectsSnapshot.entrySet()) {
32 | clientLevelData.getLevelData().replacePlaceable(entry.getKey(), entry.getValue().getCopy());
33 | }
34 | }
35 |
36 | @Override
37 | public UndoCommand getRedoCommand() {
38 | return new UndoAssetTransform(clientLevelData, clientLevelData.getSelectedPlaceables());
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public String getUndoMessage() {
44 | return LangManager.getItem("undoTransform");
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public String getRedoMessage() {
50 | return LangManager.getItem("redoTransform");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoAssetTypeChange.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.level.ClientLevelData;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 | import java.util.Set;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 11/09/2016 (DD/MM/YYYY)
16 | */
17 | public class UndoAssetTypeChange extends UndoCommand {
18 |
19 | @NotNull private Map placedObjectsSnapshot = new HashMap<>();
20 |
21 | public UndoAssetTypeChange(@NotNull ClientLevelData clientLevelData, @NotNull Set selectedPlaceables) {
22 | super(clientLevelData);
23 |
24 | for (String name : selectedPlaceables) {
25 | placedObjectsSnapshot.put(name, clientLevelData.getLevelData().getPlaceable(name).getCopy());
26 | }
27 | }
28 |
29 | @Override
30 | public void undo() {
31 | for (Map.Entry entry : placedObjectsSnapshot.entrySet()) {
32 | clientLevelData.getLevelData().replacePlaceable(entry.getKey(), entry.getValue().getCopy());
33 | }
34 | }
35 |
36 | @Override
37 | public UndoCommand getRedoCommand() {
38 | return new UndoAssetTypeChange(clientLevelData, clientLevelData.getSelectedPlaceables());
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public String getUndoMessage() {
44 | return LangManager.getItem("undoTypeChange");
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public String getRedoMessage() {
50 | return LangManager.getItem("redoTypeChange");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/Material.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | import com.owens.oobjloader.parser.BuilderInterface;
13 |
14 |
15 | public class Material {
16 |
17 | public String name;
18 | public ReflectivityTransmiss ka = new ReflectivityTransmiss();
19 | public ReflectivityTransmiss kd = new ReflectivityTransmiss();
20 | public ReflectivityTransmiss ks = new ReflectivityTransmiss();
21 | public ReflectivityTransmiss tf = new ReflectivityTransmiss();
22 | public int illumModel = 0;
23 | public boolean dHalo = false;
24 | public double dFactor = 0.0;
25 | public double nsExponent = 0.0;
26 | public double sharpnessValue = 0.0;
27 | public double niOpticalDensity = 0.0;
28 | public String mapKaFilename = null;
29 | public String mapKdFilename = null;
30 | public String mapKsFilename = null;
31 | public String mapNsFilename = null;
32 | public String mapDFilename = null;
33 | public String decalFilename = null;
34 | public String dispFilename = null;
35 | public String bumpFilename = null;
36 | public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN;
37 | public String reflFilename = null;
38 |
39 | public Material(String name) {
40 | this.name = name;
41 | }
42 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoObjectItemGroupChange.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.level.ClientLevelData;
4 | import craftedcart.smblevelworkshop.project.ProjectManager;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 | import java.util.Set;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 18/04/2017 (DD/MM/YYYY)
16 | */
17 | public class UndoObjectItemGroupChange extends UndoCommand {
18 |
19 | @NotNull private Map placedObjectsSnapshot = new HashMap<>(); //Object name mapped to item group name
20 |
21 | public UndoObjectItemGroupChange(@NotNull ClientLevelData clientLevelData, @NotNull Set selectedObjects) {
22 | super(clientLevelData);
23 |
24 | for (String name : selectedObjects) {
25 | placedObjectsSnapshot.put(name, ProjectManager.getCurrentLevelData().getObjectItemGroupName(name));
26 | }
27 | }
28 |
29 | @Override
30 | public void undo() {
31 | for (Map.Entry entry : placedObjectsSnapshot.entrySet()) {
32 | clientLevelData.getLevelData().changeObjectItemGroup(entry.getKey(), entry.getValue());
33 | }
34 | }
35 |
36 | @Override
37 | public UndoCommand getRedoCommand() {
38 | return new UndoObjectItemGroupChange(clientLevelData, clientLevelData.getSelectedPlaceables());
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public String getUndoMessage() {
44 | return LangManager.getItem("undoItemGroupChange");
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public String getRedoMessage() {
50 | return LangManager.getItem("redoItemGroupChange");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoPlaceableItemGroupChange.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.level.ClientLevelData;
4 | import craftedcart.smblevelworkshop.project.ProjectManager;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 | import java.util.Set;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 18/04/2017 (DD/MM/YYYY)
16 | */
17 | public class UndoPlaceableItemGroupChange extends UndoCommand {
18 |
19 | @NotNull private Map placedObjectsSnapshot = new HashMap<>(); //Placeable name mapped to item group name
20 |
21 | public UndoPlaceableItemGroupChange(@NotNull ClientLevelData clientLevelData, @NotNull Set selectedPlaceables) {
22 | super(clientLevelData);
23 |
24 | for (String name : selectedPlaceables) {
25 | placedObjectsSnapshot.put(name, ProjectManager.getCurrentLevelData().getPlaceableItemGroupName(name));
26 | }
27 | }
28 |
29 | @Override
30 | public void undo() {
31 | for (Map.Entry entry : placedObjectsSnapshot.entrySet()) {
32 | clientLevelData.getLevelData().changePlaceableItemGroup(entry.getKey(), entry.getValue());
33 | }
34 | }
35 |
36 | @Override
37 | public UndoCommand getRedoCommand() {
38 | return new UndoPlaceableItemGroupChange(clientLevelData, clientLevelData.getSelectedPlaceables());
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public String getUndoMessage() {
44 | return LangManager.getItem("undoItemGroupChange");
45 | }
46 |
47 | @Nullable
48 | @Override
49 | public String getRedoMessage() {
50 | return LangManager.getItem("redoItemGroupChange");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/TypeSelectorOverlayScreen.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import craftedcart.smblevelworkshop.resource.LangManager;
4 | import io.github.craftedcart.fluidui.FluidUIScreen;
5 | import io.github.craftedcart.fluidui.component.ListBox;
6 | import io.github.craftedcart.fluidui.component.TextButton;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * @author CraftedCart
12 | * Created on 14/09/2016 (DD/MM/YYYY)
13 | */
14 | public class TypeSelectorOverlayScreen extends FluidUIScreen {
15 |
16 | public TypeSelectorOverlayScreen(double mousePercentY, List options) {
17 | init(mousePercentY, options);
18 | }
19 |
20 | private void init(double mousePercentY, List options) {
21 | setTheme(new DefaultUITheme());
22 |
23 | final ListBox listBox = new ListBox();
24 | listBox.setOnInitAction(() -> {
25 | listBox.setTopLeftPos(-256, -38);
26 | listBox.setBottomRightPos(0, 38);
27 | listBox.setTopLeftAnchor(1, mousePercentY);
28 | listBox.setBottomRightAnchor(1, mousePercentY);
29 | });
30 | addChildComponent("listBox", listBox);
31 |
32 | for (String string : options) {
33 | final TextButton button = new TextButton();
34 | button.setOnInitAction(() -> {
35 | button.setText(LangManager.getItem(string));
36 | button.setTopLeftPos(0, 0);
37 | button.setBottomRightPos(0, 24);
38 | });
39 | button.setOnLMBAction(() -> selectType(string));
40 | listBox.addChildComponent(string + "TypeButton", button);
41 | }
42 |
43 | }
44 |
45 | private void selectType(String type) {
46 | assert parentComponent instanceof MainScreen;
47 |
48 | MainScreen mainScreen = (MainScreen) parentComponent;
49 | mainScreen.setTypeForSelectedPlaceables(type);
50 |
51 | mainScreen.setOverlayUiScreen(null);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/ScaleTextFields.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.ui.MainScreen;
4 | import craftedcart.smblevelworkshop.util.EnumAxis;
5 | import craftedcart.smblevelworkshop.util.ITransformable;
6 | import craftedcart.smblevelworkshop.util.PosXYZ;
7 | import io.github.craftedcart.fluidui.component.TextField;
8 | import org.jetbrains.annotations.NotNull;
9 | import org.jetbrains.annotations.Nullable;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 01/11/2016 (DD/MM/YYYY)
16 | */
17 | public abstract class ScaleTextFields extends XYZTextFields {
18 |
19 | public ScaleTextFields(@NotNull MainScreen mainScreen, @Nullable TextField nextTextField) {
20 | super(mainScreen, nextTextField);
21 | }
22 |
23 | @Override
24 | public void valueChanged(PosXYZ newValue, EnumAxis axis, List transformables) {
25 | if (axis == EnumAxis.X) {
26 | for (ITransformable transformable : transformables) {
27 | if (transformable.canScale()) {
28 | transformable.setScale(new PosXYZ(newValue.x, transformable.getScale().y, transformable.getScale().z));
29 | }
30 | }
31 | } else if (axis == EnumAxis.Y) {
32 | for (ITransformable transformable : transformables) {
33 | if (transformable.canScale()) {
34 | transformable.setScale(new PosXYZ(transformable.getScale().x, newValue.y, transformable.getScale().z));
35 | }
36 | }
37 | } else if (axis == EnumAxis.Z) {
38 | for (ITransformable transformable : transformables) {
39 | if (transformable.canScale()) {
40 | transformable.setScale(new PosXYZ(transformable.getScale().x, transformable.getScale().y, newValue.z));
41 | }
42 | }
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/PositionTextFields.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.ui.MainScreen;
4 | import craftedcart.smblevelworkshop.util.EnumAxis;
5 | import craftedcart.smblevelworkshop.util.ITransformable;
6 | import craftedcart.smblevelworkshop.util.PosXYZ;
7 | import io.github.craftedcart.fluidui.component.TextField;
8 | import org.jetbrains.annotations.NotNull;
9 | import org.jetbrains.annotations.Nullable;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 01/11/2016 (DD/MM/YYYY)
16 | */
17 | public abstract class PositionTextFields extends XYZTextFields {
18 |
19 | public PositionTextFields(@NotNull MainScreen mainScreen, @Nullable TextField nextTextField) {
20 | super(mainScreen, nextTextField);
21 | }
22 |
23 | @Override
24 | public void valueChanged(PosXYZ newValue, EnumAxis axis, List transformables) {
25 | if (axis == EnumAxis.X) {
26 | for (ITransformable transformable : transformables) {
27 | if (transformable.canMoveX()) {
28 | transformable.setPosition(new PosXYZ(newValue.x, transformable.getPosition().y, transformable.getPosition().z));
29 | }
30 | }
31 | } else if (axis == EnumAxis.Y) {
32 | for (ITransformable transformable : transformables) {
33 | if (transformable.canMoveY()) {
34 | transformable.setPosition(new PosXYZ(transformable.getPosition().x, newValue.y, transformable.getPosition().z));
35 | }
36 | }
37 | } else if (axis == EnumAxis.Z) {
38 | for (ITransformable transformable : transformables) {
39 | if (transformable.canMoveZ()) {
40 | transformable.setPosition(new PosXYZ(transformable.getPosition().x, transformable.getPosition().y, newValue.z));
41 | }
42 | }
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/IAsset.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.ResourceShaderProgram;
5 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | /**
11 | * @author CraftedCart
12 | * Created on 10/09/2016 (DD/MM/YYYY)
13 | */
14 | public interface IAsset extends Cloneable {
15 |
16 | @NotNull public String getName();
17 | @NotNull public ResourceModel getModel();
18 |
19 | @NotNull
20 | default public UIColor getColor() {
21 | return UIColor.pureWhite();
22 | }
23 |
24 | /**
25 | * @return Null if this asset has no types, else it returns an array of type keys (That can be localized)
26 | */
27 | @Nullable
28 | default public String[] getValidTypes() {
29 | return null;
30 | }
31 |
32 | @Nullable
33 | default public String getType() {
34 | return null;
35 | }
36 |
37 | @Nullable
38 | default public String getGameType() {
39 | return null;
40 | }
41 |
42 | default public void setType(String type) {}
43 |
44 | default public boolean canGrabX() {
45 | return true;
46 | }
47 |
48 | default public boolean canGrabY() {
49 | return true;
50 | }
51 |
52 | default public boolean canGrabZ() {
53 | return true;
54 | }
55 |
56 | default public boolean canRotate() {
57 | return true;
58 | }
59 |
60 | default public boolean canScale() {
61 | return true;
62 | }
63 |
64 | public IAsset getCopy();
65 |
66 | @NotNull
67 | default public ResourceShaderProgram getShaderProgram() {
68 | return ResourceManager.getShaderProgram("colShaderProgram");
69 | }
70 |
71 | default public boolean isShaderTextured() {
72 | return false;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource;
2 |
3 | import craftedcart.smblevelworkshop.exception.GLSLCompileException;
4 | import craftedcart.smblevelworkshop.util.LogHelper;
5 | import org.lwjgl.LWJGLException;
6 | import org.lwjgl.opengl.GL11;
7 | import org.lwjgl.opengl.GL20;
8 |
9 | import java.io.*;
10 |
11 | import static craftedcart.smblevelworkshop.Window.drawable;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 06/04/2016 (DD/MM/YYYY)
16 | */
17 | public class ResourceShader implements IResource {
18 |
19 | private int shaderID;
20 |
21 | /**
22 | * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER})
23 | * @param file the file where the shader is stored
24 | */
25 | public ResourceShader(int shaderType, File file) throws IOException, LWJGLException, GLSLCompileException {
26 | drawable.makeCurrent();
27 |
28 | shaderID = GL20.glCreateShader(shaderType);
29 | StringBuilder source = new StringBuilder();
30 |
31 | BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
32 |
33 | String line;
34 | while ((line = reader.readLine()) != null) {
35 | source.append(line).append('\n');
36 | }
37 |
38 | reader.close();
39 |
40 | GL20.glShaderSource(shaderID, source);
41 | GL20.glCompileShader(shaderID);
42 |
43 | if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { //If it failed to compile
44 | LogHelper.error(getClass(), String.format("Failed to compile the shader at \"%s\"", file.getPath()));
45 |
46 | // IntBuffer logLength = ByteBuffer.allocateDirect(8).asIntBuffer();
47 | // GL20.glGetShaderi(shaderID, GL20.GL_INFO_LOG_LENGTH);
48 | String shaderLog = GL20.glGetShaderInfoLog(shaderID, 8192);
49 |
50 | throw new GLSLCompileException(shaderLog); //Get the error and throw an exception
51 | }
52 |
53 | drawable.releaseContext();
54 | }
55 |
56 | public int getShaderID() {
57 | return shaderID;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/FPSOverlay.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component;
2 |
3 | import craftedcart.smblevelworkshop.resource.LangManager;
4 | import io.github.craftedcart.fluidui.component.Label;
5 | import io.github.craftedcart.fluidui.component.Panel;
6 | import io.github.craftedcart.fluidui.plugin.AbstractComponentPlugin;
7 | import io.github.craftedcart.fluidui.util.UIUtils;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * @author CraftedCart
14 | * Created on 04/02/2017 (DD/MM/YYYY)
15 | */
16 | public class FPSOverlay extends Panel {
17 |
18 | @Override
19 | public void postInit() {
20 | super.postInit();
21 |
22 | Label fpsLabel = new Label();
23 | fpsLabel.setOnInitAction(() -> {
24 | fpsLabel.setTopLeftPos(0, 0);
25 | fpsLabel.setBottomRightPos(0, 0);
26 | fpsLabel.setTopLeftAnchor(0, 0);
27 | fpsLabel.setBottomRightAnchor(1, 1);
28 | fpsLabel.addPlugin(new FPSLabelPlugin());
29 | });
30 | addChildComponent("fpsLabel", fpsLabel);
31 | }
32 |
33 | private class FPSLabelPlugin extends AbstractComponentPlugin {
34 |
35 | private String fpsLoc;
36 | private String avgLoc;
37 | private List deltaAvgList = new ArrayList<>();
38 |
39 | FPSLabelPlugin() {
40 | fpsLoc = LangManager.getItem("fps");
41 | avgLoc = LangManager.getItem("5sAverage");
42 | }
43 |
44 | @Override
45 | public void onPreDraw() {
46 | double delta = UIUtils.getDelta();
47 | double fps = 1 / delta;
48 | deltaAvgList.add(delta);
49 |
50 | double totalDeltaAvg = 0;
51 | for (double value : deltaAvgList) totalDeltaAvg += value;
52 |
53 | while (totalDeltaAvg > 5) { //5s Average
54 | totalDeltaAvg -= deltaAvgList.get(0);
55 | deltaAvgList.remove(0);
56 | }
57 |
58 | double fpsAvg = 1 / (totalDeltaAvg / deltaAvgList.size());
59 |
60 | ((Label) linkedComponent).setText(String.format("%s: %05.2f | %s %05.2f", fpsLoc, fps, avgLoc, fpsAvg));
61 | }
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | /**
9 | * @author CraftedCart
10 | * Created on 04/04/2016 (DD/MM/YYYY)
11 | */
12 | public class LangManager {
13 |
14 | // >
15 | @NotNull private static Map> localeMap = new HashMap<>();
16 | @NotNull private static String selectedLang = "en_US";
17 |
18 | /**
19 | * Add an item given a locale, key and value
20 | *
21 | * @param locale The language locale (eg: en_US)
22 | * @param key The identifier
23 | * @param value The translated string
24 | */
25 | public static void addItem(String locale, String key, String value) {
26 | if (localeMap.containsKey(locale)) {
27 | Map langMap = localeMap.get(locale);
28 | langMap.put(key, value);
29 | localeMap.put(locale, langMap);
30 | } else {
31 | Map langMap = new HashMap<>();
32 | langMap.put(key, value);
33 | localeMap.put(locale, langMap);
34 | }
35 | }
36 |
37 | /**
38 | * Get a translated string, given a locale and key
39 | *
40 | * @param locale The language locale (eg: en_US)
41 | * @param key The identifier
42 | * @return The translated string, or the key if the entry wasn't found
43 | */
44 | public static String getItem(String locale, String key) {
45 | if (localeMap.containsKey(locale)) {
46 | if (localeMap.get(locale).containsKey(key)) {
47 | return localeMap.get(locale).get(key);
48 | } else {
49 | return key;
50 | }
51 | } else {
52 | return key;
53 | }
54 | }
55 |
56 | public static String getItem(String key) {
57 | return getItem(selectedLang, key);
58 | }
59 |
60 | public static void setSelectedLang(@NotNull String selectedLang) {
61 | LangManager.selectedLang = selectedLang;
62 | }
63 |
64 | @NotNull
65 | public static String getSelectedLang() {
66 | return selectedLang;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/PlaceableScaleTextFields.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.project.ProjectManager;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import craftedcart.smblevelworkshop.ui.MainScreen;
7 | import craftedcart.smblevelworkshop.undo.UndoAssetTransform;
8 | import craftedcart.smblevelworkshop.util.ITransformable;
9 | import io.github.craftedcart.fluidui.component.TextField;
10 | import io.github.craftedcart.fluidui.util.UIColor;
11 | import org.jetbrains.annotations.NotNull;
12 | import org.jetbrains.annotations.Nullable;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * @author CraftedCart
18 | * Created on 30/10/2016 (DD/MM/YYYY)
19 | */
20 | public class PlaceableScaleTextFields extends ScaleTextFields {
21 |
22 | public PlaceableScaleTextFields(@NotNull MainScreen mainScreen, @Nullable TextField nextTextField) {
23 | super(mainScreen, nextTextField);
24 | }
25 |
26 | @Nullable
27 | @Override
28 | protected Double valueConfirmedParseNumber(String value, List transformablesToPopulate) {
29 | double newValue;
30 |
31 | try {
32 | newValue = Double.parseDouble(value);
33 |
34 | assert ProjectManager.getCurrentClientLevelData() != null;
35 |
36 | mainScreen.addUndoCommand(new UndoAssetTransform(ProjectManager.getCurrentClientLevelData(),
37 | ProjectManager.getCurrentClientLevelData().getSelectedPlaceables()));
38 |
39 | for (String name : ProjectManager.getCurrentClientLevelData().getSelectedPlaceables()) {
40 | Placeable placeable = ProjectManager.getCurrentLevelData().getPlaceable(name);
41 | transformablesToPopulate.add(placeable);
42 | }
43 |
44 | return newValue;
45 | } catch (NumberFormatException e) {
46 | mainScreen.sendNotif(LangManager.getItem("invalidNumber"), UIColor.matRed());
47 | }
48 |
49 | return null; //Failed to parse the number
50 | }
51 |
52 | @Override
53 | public void postValuesChanged() {
54 | mainScreen.updatePropertiesPlaceablesPanel();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/PlaceablePositionTextFields.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.project.ProjectManager;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import craftedcart.smblevelworkshop.ui.MainScreen;
7 | import craftedcart.smblevelworkshop.undo.UndoAssetTransform;
8 | import craftedcart.smblevelworkshop.util.ITransformable;
9 | import io.github.craftedcart.fluidui.component.TextField;
10 | import io.github.craftedcart.fluidui.util.UIColor;
11 | import org.jetbrains.annotations.NotNull;
12 | import org.jetbrains.annotations.Nullable;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * @author CraftedCart
18 | * Created on 30/10/2016 (DD/MM/YYYY)
19 | */
20 | public class PlaceablePositionTextFields extends PositionTextFields {
21 |
22 | public PlaceablePositionTextFields(@NotNull MainScreen mainScreen, @Nullable TextField nextTextField) {
23 | super(mainScreen, nextTextField);
24 | }
25 |
26 | @Nullable
27 | @Override
28 | protected Double valueConfirmedParseNumber(String value, List transformablesToPopulate) {
29 | double newValue;
30 |
31 | try {
32 | newValue = Double.parseDouble(value);
33 |
34 | assert ProjectManager.getCurrentClientLevelData() != null;
35 |
36 | mainScreen.addUndoCommand(new UndoAssetTransform(ProjectManager.getCurrentClientLevelData(),
37 | ProjectManager.getCurrentClientLevelData().getSelectedPlaceables()));
38 |
39 | for (String name : ProjectManager.getCurrentClientLevelData().getSelectedPlaceables()) {
40 | Placeable placeable = ProjectManager.getCurrentLevelData().getPlaceable(name);
41 | transformablesToPopulate.add(placeable);
42 | }
43 |
44 | return newValue;
45 | } catch (NumberFormatException e) {
46 | mainScreen.sendNotif(LangManager.getItem("invalidNumber"), UIColor.matRed());
47 | }
48 |
49 | return null; //Failed to parse the number
50 | }
51 |
52 | @Override
53 | public void postValuesChanged() {
54 | mainScreen.updatePropertiesPlaceablesPanel();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/PlaceableRotationTextFields.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.project.ProjectManager;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import craftedcart.smblevelworkshop.ui.MainScreen;
7 | import craftedcart.smblevelworkshop.undo.UndoAssetTransform;
8 | import craftedcart.smblevelworkshop.util.ITransformable;
9 | import io.github.craftedcart.fluidui.component.TextField;
10 | import io.github.craftedcart.fluidui.util.UIColor;
11 | import org.jetbrains.annotations.NotNull;
12 | import org.jetbrains.annotations.Nullable;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * @author CraftedCart
18 | * Created on 30/10/2016 (DD/MM/YYYY)
19 | */
20 | public class PlaceableRotationTextFields extends RotationTextFields {
21 |
22 | public PlaceableRotationTextFields(@NotNull MainScreen mainScreen, @Nullable TextField nextTextField) {
23 | super(mainScreen, nextTextField);
24 | }
25 |
26 | @Nullable
27 | @Override
28 | protected Double valueConfirmedParseNumber(String value, List transformablesToPopulate) {
29 | double newValue;
30 |
31 | try {
32 | newValue = Double.parseDouble(value);
33 |
34 | assert ProjectManager.getCurrentClientLevelData() != null;
35 |
36 | mainScreen.addUndoCommand(new UndoAssetTransform(ProjectManager.getCurrentClientLevelData(),
37 | ProjectManager.getCurrentClientLevelData().getSelectedPlaceables()));
38 |
39 | for (String name : ProjectManager.getCurrentClientLevelData().getSelectedPlaceables()) {
40 | Placeable placeable = ProjectManager.getCurrentLevelData().getPlaceable(name);
41 | transformablesToPopulate.add(placeable);
42 | }
43 |
44 | return newValue;
45 | } catch (NumberFormatException e) {
46 | mainScreen.sendNotif(LangManager.getItem("invalidNumber"), UIColor.matRed());
47 | }
48 |
49 | return null; //Failed to parse the number
50 | }
51 |
52 | @Override
53 | public void postValuesChanged() {
54 | mainScreen.updatePropertiesPlaceablesPanel();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoAddPlaceable.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.level.ClientLevelData;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import craftedcart.smblevelworkshop.ui.MainScreen;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 11/09/2016 (DD/MM/YYYY)
16 | */
17 | public class UndoAddPlaceable extends UndoCommand {
18 |
19 | @NotNull private List names;
20 | @NotNull private List placeables = new ArrayList<>();
21 | @NotNull private MainScreen mainScreen;
22 |
23 | public UndoAddPlaceable(@NotNull ClientLevelData clientLevelData, @NotNull MainScreen mainScreen, @NotNull List names, @NotNull List placeables) {
24 | super(clientLevelData);
25 |
26 | this.names = new ArrayList<>(names);
27 | for (Placeable placeable : placeables) {
28 | this.placeables.add(placeable.getCopy());
29 | }
30 | this.mainScreen = mainScreen;
31 | }
32 |
33 | @Override
34 | public void undo() {
35 | for (String name : names) {
36 | clientLevelData.getLevelData().removePlaceable(name);
37 | clientLevelData.removeSelectedPlaceable(name);
38 | mainScreen.outlinerPlaceablesListBox.removeChildComponent(name + "OutlinerPlaceable");
39 | }
40 | }
41 |
42 | @Override
43 | public UndoCommand getRedoCommand() {
44 | List newList = new ArrayList<>();
45 | for (Placeable placeable : placeables) {
46 | newList.add(placeable.getCopy());
47 | }
48 |
49 | return new UndoRemovePlaceable(clientLevelData, mainScreen, names, newList);
50 | }
51 |
52 | @Nullable
53 | @Override
54 | public String getUndoMessage() {
55 | return LangManager.getItem("undoAddPlaceable");
56 | }
57 |
58 | @Nullable
59 | @Override
60 | public String getRedoMessage() {
61 | if (names.size() > 1) {
62 | return String.format(LangManager.getItem("redoAddPlaceablePlural"), names.size());
63 | } else {
64 | return LangManager.getItem("redoAddPlaceable");
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | import io.github.craftedcart.fluidui.util.UIColor;
4 |
5 | /**
6 | * @author CraftedCart
7 | * Created on 30/10/2016 (DD/MM/YYYY)
8 | */
9 | public class MathUtils {
10 |
11 | public static double lerp(double a, double b, double f) {
12 | return a + f * (b - a);
13 | }
14 |
15 | /**
16 | * Linearly interpolates between two {@link UIColor}s
17 | *
18 | * @param a The starting {@link UIColor}
19 | * @param b The ending {@link UIColor}
20 | * @param f The percentage between the two {@link UIColor}
21 | * @return The {@link UIColor} which if f% between a and b
22 | */
23 | public static UIColor lerpUIColor(UIColor a, UIColor b, float f) {
24 | return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255),
25 | a.g * 255 + f * (b.g * 255 - a.g * 255),
26 | a.b * 255 + f * (b.b * 255 - a.b * 255),
27 | a.a * 255 + f * (b.a * 255 - a.a * 255));
28 | }
29 |
30 | public static double clamp(double val, double min, double max) {
31 | return Math.max(min, Math.min(max, val));
32 | }
33 |
34 | public static PosXYZ normalizeRotation(PosXYZ rot) {
35 | while (rot.x >= 360) {
36 | rot.x -= 360;
37 | }
38 |
39 | while (rot.y >= 360) {
40 | rot.y -= 360;
41 | }
42 |
43 | while (rot.z >= 360) {
44 | rot.z -= 360;
45 | }
46 |
47 | while (rot.x < 0) {
48 | rot.x += 360;
49 | }
50 |
51 | while (rot.y < 0) {
52 | rot.y += 360;
53 | }
54 |
55 | while (rot.z < 0) {
56 | rot.z += 360;
57 | }
58 |
59 | return rot;
60 | }
61 |
62 | public static boolean isInRange(double val, double min, double max) {
63 | return val >= min && val <= max;
64 | }
65 |
66 | public static float snapTo(float val, float snapTo) {
67 | float roundMultiplier = 1.0f / snapTo;
68 | return Math.round(val * roundMultiplier) / roundMultiplier;
69 | }
70 |
71 | /**
72 | * @param t A value from 0 to 1
73 | * @return Quadratic interpolated value between 0 and 1
74 | */
75 | public static float cubicEaseInOut(float t) {
76 | return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/timeline/TimelinePlayhead.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.timeline;
2 |
3 | import io.github.craftedcart.fluidui.FontCache;
4 | import io.github.craftedcart.fluidui.component.Panel;
5 | import io.github.craftedcart.fluidui.util.PosXY;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import io.github.craftedcart.fluidui.util.UIUtils;
8 | import org.jetbrains.annotations.NotNull;
9 | import org.newdawn.slick.Color;
10 | import org.newdawn.slick.UnicodeFont;
11 | import org.newdawn.slick.opengl.TextureImpl;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 31/10/2016 (DD/MM/YYYY)
16 | */
17 | public class TimelinePlayhead extends Panel {
18 |
19 | private UnicodeFont font;
20 | @NotNull private String rightText = "";
21 | @NotNull private String leftText = "";
22 |
23 | public TimelinePlayhead() {
24 | super();
25 | font = FontCache.getUnicodeFont("Roboto-Regular", 12);
26 | }
27 |
28 | @Override
29 | public void draw() {
30 | super.draw();
31 |
32 | UIUtils.drawQuad(
33 | new PosXY(bottomRightPx.x, topLeftPx.y),
34 | new PosXY(bottomRightPx.x, topLeftPx.y + 16),
35 | new PosXY(bottomRightPx.x + 38, topLeftPx.y + 16),
36 | new PosXY(bottomRightPx.x + 62, topLeftPx.y),
37 | backgroundColor
38 | );
39 |
40 | UIUtils.drawQuad(
41 | new PosXY(topLeftPx.x - 62, topLeftPx.y),
42 | new PosXY(topLeftPx.x - 38, topLeftPx.y + 16),
43 | new PosXY(topLeftPx.x, topLeftPx.y + 16),
44 | topLeftPx,
45 | backgroundColor
46 | );
47 |
48 | UIColor textCol = UIColor.matWhite();
49 | //Right text
50 | font.drawString((float) bottomRightPx.x, (float) topLeftPx.y, rightText, new Color((float) textCol.r, (float) textCol.g, (float) textCol.b, (float) textCol.a));
51 | //Left text
52 | font.drawString((float) topLeftPx.x - 40, (float) topLeftPx.y, leftText, new Color((float) textCol.r, (float) textCol.g, (float) textCol.b, (float) textCol.a));
53 | TextureImpl.bindNone();
54 | }
55 |
56 | public void setRightText(@NotNull String rightText) {
57 | this.rightText = rightText;
58 | }
59 |
60 | public void setLeftText(@NotNull String leftText) {
61 | this.leftText = leftText;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | import org.apache.logging.log4j.Level;
4 | import org.apache.logging.log4j.LogManager;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 14/03/2016 (DD/MM/YYYY)
12 | */
13 | public class LogHelper {
14 |
15 | public static List log = new ArrayList<>();
16 |
17 | private static void log(Class clazz, Level logLevel, Object object) {
18 | LogManager.getLogger(clazz).log(logLevel, object);
19 | log.add(new LogEntry(clazz, logLevel, object));
20 | if (log.size() > 1024) {
21 | log.remove(0);
22 | }
23 | }
24 |
25 | public static void all(Class clazz, Object object) {
26 | log(clazz, Level.ALL, object);
27 | }
28 |
29 | public static void fatal(Class clazz, Object object) {
30 | log(clazz, Level.FATAL, object);
31 | }
32 |
33 | public static void error(Class clazz, Object object) {
34 | log(clazz, Level.ERROR, object);
35 | }
36 |
37 | public static void warn(Class clazz, Object object) {
38 | log(clazz, Level.WARN, object);
39 | }
40 |
41 | public static void info(Class clazz, Object object) {
42 | log(clazz, Level.INFO, object);
43 | }
44 |
45 | public static void debug(Class clazz, Object object) {
46 | log(clazz, Level.DEBUG, object);
47 | }
48 |
49 | public static void trace(Class clazz, Object object) {
50 | log(clazz, Level.TRACE, object);
51 | }
52 |
53 | public static void off(Class clazz, Object object) {
54 | log(clazz, Level.OFF, object);
55 | }
56 |
57 | public static String stackTraceToString(Throwable e) {
58 | StringBuilder sb = new StringBuilder();
59 | for (StackTraceElement element : e.getStackTrace()) {
60 | sb.append(" at ");
61 | sb.append(element.toString());
62 | sb.append("\n");
63 | }
64 | return sb.toString();
65 | }
66 |
67 | public static class LogEntry {
68 |
69 | public Class clazz;
70 | public Level logLevel;
71 | public Object object;
72 |
73 | public LogEntry(Class clazz, Level logLevel, Object object) {
74 | this.clazz = clazz;
75 | this.logLevel = logLevel;
76 | this.object = object;
77 | }
78 |
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/RotationTextFields.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.ui.MainScreen;
4 | import craftedcart.smblevelworkshop.util.EnumAxis;
5 | import craftedcart.smblevelworkshop.util.ITransformable;
6 | import craftedcart.smblevelworkshop.util.MathUtils;
7 | import craftedcart.smblevelworkshop.util.PosXYZ;
8 | import io.github.craftedcart.fluidui.component.TextField;
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * @author CraftedCart
16 | * Created on 01/11/2016 (DD/MM/YYYY)
17 | */
18 | public abstract class RotationTextFields extends XYZTextFields {
19 |
20 | private boolean shouldNormalizeRotation = true;
21 |
22 | public RotationTextFields(@NotNull MainScreen mainScreen, @Nullable TextField nextTextField) {
23 | super(mainScreen, nextTextField);
24 | }
25 |
26 | @Override
27 | public void valueChanged(PosXYZ newValue, EnumAxis axis, List transformables) {
28 | if (shouldNormalizeRotation) {
29 | newValue = MathUtils.normalizeRotation(newValue);
30 | }
31 |
32 | if (axis == EnumAxis.X) {
33 | for (ITransformable transformable : transformables) {
34 | if (transformable.canRotate()) {
35 | transformable.setRotation(new PosXYZ(newValue.x, transformable.getRotation().y, transformable.getRotation().z));
36 | }
37 | }
38 | } else if (axis == EnumAxis.Y) {
39 | for (ITransformable transformable : transformables) {
40 | if (transformable.canRotate()) {
41 | transformable.setRotation(new PosXYZ(transformable.getRotation().x, newValue.y, transformable.getRotation().z));
42 | }
43 | }
44 | } else if (axis == EnumAxis.Z) {
45 | for (ITransformable transformable : transformables) {
46 | if (transformable.canRotate()) {
47 | transformable.setRotation(new PosXYZ(transformable.getRotation().x, transformable.getRotation().y, newValue.z));
48 | }
49 | }
50 | }
51 | }
52 |
53 | public void setShouldNormalizeRotation(boolean shouldNormalizeRotation) {
54 | this.shouldNormalizeRotation = shouldNormalizeRotation;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/.idea/modules/lib/FluidUI/FluidUI_main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/builder/Face.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.builder;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | import java.util.ArrayList;
13 |
14 | public class Face {
15 |
16 | public ArrayList vertices = new ArrayList();
17 | public Material material = null;
18 | public Material map = null;
19 | public VertexNormal faceNormal = new VertexNormal(0, 0, 0);
20 | public String objectName;
21 |
22 | public Face() {
23 | }
24 |
25 | public void add(FaceVertex vertex) {
26 | vertices.add(vertex);
27 | }
28 |
29 | // @TODO: This code assumes the face is a triangle.
30 | public void calculateTriangleNormal() {
31 | float[] edge1 = new float[3];
32 | float[] edge2 = new float[3];
33 | float[] normal = new float[3];
34 | VertexGeometric v1 = vertices.get(0).v;
35 | VertexGeometric v2 = vertices.get(1).v;
36 | VertexGeometric v3 = vertices.get(2).v;
37 | float[] p1 = {v1.x, v1.y, v1.z};
38 | float[] p2 = {v2.x, v2.y, v2.z};
39 | float[] p3 = {v3.x, v3.y, v3.z};
40 |
41 | edge1[0] = p2[0] - p1[0];
42 | edge1[1] = p2[1] - p1[1];
43 | edge1[2] = p2[2] - p1[2];
44 |
45 | edge2[0] = p3[0] - p2[0];
46 | edge2[1] = p3[1] - p2[1];
47 | edge2[2] = p3[2] - p2[2];
48 |
49 | normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1];
50 | normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2];
51 | normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0];
52 |
53 | faceNormal.x = normal[0];
54 | faceNormal.y = normal[1];
55 | faceNormal.z = normal[2];
56 | }
57 |
58 | public String toString() {
59 | String result = "\tvertices: "+vertices.size()+" :\n";
60 | for(FaceVertex f : vertices) {
61 | result += " \t\t( "+f.toString()+" )\n";
62 | }
63 | return result;
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/undo/UndoRemovePlaceable.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.undo;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import craftedcart.smblevelworkshop.level.ClientLevelData;
5 | import craftedcart.smblevelworkshop.resource.LangManager;
6 | import craftedcart.smblevelworkshop.ui.MainScreen;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 11/09/2016 (DD/MM/YYYY)
16 | */
17 | public class UndoRemovePlaceable extends UndoCommand {
18 |
19 | @NotNull private List names;
20 | @NotNull private List placeables = new ArrayList<>();
21 | @NotNull private MainScreen mainScreen;
22 |
23 | public UndoRemovePlaceable(@NotNull ClientLevelData clientLevelData, @NotNull MainScreen mainScreen, @NotNull List names, @NotNull List placeables) {
24 | super(clientLevelData);
25 |
26 | this.names = new ArrayList<>(names);
27 | for (Placeable placeable : placeables) {
28 | this.placeables.add(placeable.getCopy());
29 | }
30 | this.mainScreen = mainScreen;
31 | }
32 |
33 | @Override
34 | public void undo() {
35 | for (int i = 0; i < names.size(); i++) {
36 | String name = names.get(i);
37 | Placeable placeable = placeables.get(i);
38 | clientLevelData.getLevelData().addPlaceable(name, placeable.getCopy());
39 | mainScreen.outlinerPlaceablesListBox.addChildComponent(mainScreen.getOutlinerPlaceableComponent(name));
40 | }
41 | }
42 |
43 | @Override
44 | public UndoCommand getRedoCommand() {
45 | List newList = new ArrayList<>();
46 | for (Placeable placeable : placeables) {
47 | newList.add(placeable.getCopy());
48 | }
49 |
50 | return new UndoAddPlaceable(clientLevelData, mainScreen, names, newList);
51 | }
52 |
53 | @Nullable
54 | @Override
55 | public String getUndoMessage() {
56 | if (names.size() > 1) {
57 | return String.format(LangManager.getItem("undoRemovePlaceablePlural"), names.size());
58 | } else {
59 | return LangManager.getItem("undoRemovePlaceable");
60 | }
61 | }
62 |
63 | @Nullable
64 | @Override
65 | public String getRedoMessage() {
66 | return LangManager.getItem("redoRemovePlaceable");
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetGoal.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
5 | import craftedcart.smblevelworkshop.util.LogHelper;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | /**
11 | * @author CraftedCart
12 | * Created on 10/09/2016 (DD/MM/YYYY)
13 | */
14 | public class AssetGoal implements IAsset {
15 |
16 | private String type = "blueGoal";
17 |
18 | @NotNull
19 | @Override
20 | public String getName() {
21 | return "assetGoal";
22 | }
23 |
24 | @NotNull
25 | @Override
26 | public ResourceModel getModel() {
27 | return ResourceManager.getModel("model/GOAL");
28 | }
29 |
30 | @NotNull
31 | @Override
32 | public UIColor getColor() {
33 | switch (type) {
34 | case "blueGoal":
35 | return UIColor.matBlue();
36 | case "greenGoal":
37 | return UIColor.matGreen();
38 | case "redGoal":
39 | return UIColor.matRed();
40 | default:
41 | //This shouldn't happen!
42 | return UIColor.pureWhite();
43 | }
44 | }
45 |
46 | public void setType(String type) {
47 | this.type = type;
48 | }
49 |
50 | @Override
51 | public String getType() {
52 | return type;
53 | }
54 |
55 | @Override
56 | public String[] getValidTypes() {
57 | return new String[]{"blueGoal", "greenGoal", "redGoal"};
58 | }
59 |
60 | @Nullable
61 | @Override
62 | public String getGameType() {
63 | switch (type) {
64 | case "blueGoal":
65 | return "B";
66 | case "greenGoal":
67 | return "G";
68 | case "redGoal":
69 | return "R";
70 | default:
71 | //This shouldn't happen!
72 | return "B";
73 | }
74 | }
75 |
76 | @Override
77 | public boolean canScale() {
78 | return false;
79 | }
80 |
81 | @Override
82 | public IAsset getCopy() {
83 | try {
84 | return (IAsset) clone();
85 | } catch (CloneNotSupportedException e) {
86 | LogHelper.error(getClass(), "Failed to clone IAsset");
87 | LogHelper.error(getClass(), e);
88 | return null;
89 | }
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/model/ResourceModel.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource.model;
2 |
3 | import craftedcart.smblevelworkshop.resource.IResource;
4 | import craftedcart.smblevelworkshop.resource.ResourceShaderProgram;
5 | import io.github.craftedcart.fluidui.util.UIColor;
6 | import org.lwjgl.opengl.GL11;
7 |
8 | /**
9 | * Created by CraftedCart on 25/02/2016 (DD/MM/YYYY)
10 | */
11 | public class ResourceModel implements IResource {
12 |
13 | public OBJScene scene;
14 |
15 | public ResourceModel(OBJScene scene) {
16 | this.scene = scene;
17 | }
18 |
19 | public void drawModel(ResourceShaderProgram shaderProgram, boolean setTexture) {
20 | scene.renderAll(shaderProgram, setTexture);
21 | }
22 |
23 | public void drawModel(ResourceShaderProgram shaderProgram, boolean setTexture, UIColor color) {
24 | scene.renderAll(shaderProgram, setTexture, color);
25 | }
26 |
27 | public void drawModelObject(ResourceShaderProgram shaderProgram, boolean setTexture, String name) {
28 | scene.renderObjectByName(shaderProgram, setTexture, name);
29 | }
30 |
31 | public void drawModelWireframe(ResourceShaderProgram shaderProgram, boolean setTexture) {
32 | GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
33 | scene.renderAll(shaderProgram, setTexture);
34 | GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
35 | }
36 |
37 | public void drawModelObjectWireframe(ResourceShaderProgram shaderProgram, boolean setTexture, String name) {
38 | GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
39 | scene.renderObjectByName(shaderProgram, setTexture, name);
40 | GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
41 | }
42 |
43 | public boolean hasObject(String name) {
44 | return scene.hasObject(name);
45 | }
46 |
47 | // public static void drawModel(ResourceModel m, ResourceShaderProgram shaderProgram, boolean setTexture) {
48 | // m.scene.render(shaderProgram, setTexture);
49 | // }
50 | //
51 | // public static void drawModel(ResourceModel m, ResourceShaderProgram shaderProgram, boolean setTexture, UIColor color) {
52 | // m.scene.render(shaderProgram, setTexture, color);
53 | // }
54 | //
55 | // public static void drawModelWireframe(ResourceModel m, ResourceShaderProgram shaderProgram, boolean setTexture) {
56 | // GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
57 | // m.scene.render(shaderProgram, setTexture);
58 | // GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
59 | // }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/AssetBanana.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.resource.model.ResourceModel;
5 | import craftedcart.smblevelworkshop.util.LogHelper;
6 | import io.github.craftedcart.fluidui.util.UIColor;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | /**
11 | * @author CraftedCart
12 | * Created on 10/09/2016 (DD/MM/YYYY)
13 | */
14 | public class AssetBanana implements IAsset {
15 |
16 | private String type = "singleBanana";
17 |
18 | @NotNull
19 | @Override
20 | public String getName() {
21 | return "assetBanana";
22 | }
23 |
24 | @NotNull
25 | @Override
26 | public ResourceModel getModel() {
27 | switch (type) {
28 | case "singleBanana":
29 | return ResourceManager.getModel("model/OBJ_BANANA_01_LOD150");
30 | case "bunchBanana":
31 | return ResourceManager.getModel("model/OBJ_BANANA_02_LOD100");
32 | default:
33 | //This shouldn't happen
34 | return ResourceManager.getModel("model/invalidAsset");
35 | }
36 | }
37 |
38 | @NotNull
39 | @Override
40 | public UIColor getColor() {
41 | return UIColor.matYellow();
42 | }
43 |
44 | public void setType(String type) {
45 | this.type = type;
46 | }
47 |
48 | @Override
49 | public String getType() {
50 | return type;
51 | }
52 |
53 | @Override
54 | public String[] getValidTypes() {
55 | return new String[] {"singleBanana", "bunchBanana"};
56 | }
57 |
58 | @Nullable
59 | @Override
60 | public String getGameType() {
61 | switch (type) {
62 | case "singleBanana":
63 | return "N";
64 | case "bunchBanana":
65 | return "B";
66 | default:
67 | //This shouldn't happen
68 | return "N";
69 | }
70 | }
71 |
72 | @Override
73 | public boolean canRotate() {
74 | return false;
75 | }
76 |
77 | @Override
78 | public boolean canScale() {
79 | return false;
80 | }
81 |
82 | @Override
83 | public IAsset getCopy() {
84 | try {
85 | return (IAsset) clone();
86 | } catch (CloneNotSupportedException e) {
87 | LogHelper.error(getClass(), "Failed to clone IAsset");
88 | LogHelper.error(getClass(), e);
89 | return null;
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/.idea/modules/lib/FluidUI/FluidUI_test.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/ItemButton.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import io.github.craftedcart.fluidui.component.Button;
5 | import io.github.craftedcart.fluidui.util.UIColor;
6 | import io.github.craftedcart.fluidui.util.UIUtils;
7 | import org.jetbrains.annotations.NotNull;
8 | import org.lwjgl.input.Mouse;
9 | import org.newdawn.slick.opengl.Texture;
10 |
11 | /**
12 | * @author CraftedCart
13 | * Created on 12/04/2017 (DD/MM/YYYY)
14 | */
15 | public class ItemButton extends Button {
16 |
17 | private String id;
18 | private boolean selected;
19 | @NotNull private UIColor itemGroupCol = UIColor.matGrey();
20 | private Texture colTex;
21 |
22 | @Override
23 | public void init() {
24 | super.init();
25 | colTex = ResourceManager.getTexture("image/circle").getTexture();
26 | }
27 |
28 | @Override
29 | public void componentDraw() {
30 | UIUtils.drawQuad(topLeftPx, bottomRightPx, UIColor.pureBlack());
31 |
32 | UIColor buttonBackgroundColor; //The background color of the button
33 | if (mouseOver && isEnabled) { //If the mouse is over the button
34 | if (Mouse.isButtonDown(0)) { //If LMB down
35 | buttonBackgroundColor = backgroundHitColor;
36 | } else { //LMB not down
37 | buttonBackgroundColor = backgroundActiveColor;
38 | }
39 | } else { //Mouse not over
40 | // buttonBackgroundColor = backgroundIdleColor;
41 | double alpha = selected ? 0.25 : 0.5;
42 | buttonBackgroundColor = itemGroupCol.alpha(alpha);
43 | }
44 |
45 | if (texture == null) {
46 | UIUtils.drawQuad(topLeftPx, bottomRightPx, buttonBackgroundColor);
47 | } else {
48 | buttonBackgroundColor.bindColor();
49 | if (textureSlice9 == null) {
50 | UIUtils.drawTexturedQuad(topLeftPx, bottomRightPx, texture);
51 | } else {
52 | UIUtils.drawTexturedQuad(topLeftPx, bottomRightPx, texture, textureSlice9);
53 | }
54 | }
55 |
56 | UIUtils.drawString(theme.labelFont, topLeftPx.add(18, -2), id, UIColor.matWhite()); //Draw ID label
57 |
58 | itemGroupCol.bindColor();
59 | UIUtils.drawTexturedQuad(topLeftPx, topLeftPx.add(18, 18), colTex);
60 | }
61 |
62 | public void setItemGroupCol(@NotNull UIColor itemGroupCol) {
63 | this.itemGroupCol = itemGroupCol;
64 | }
65 |
66 | public void setId(String id) {
67 | this.id = id;
68 | }
69 |
70 | public String getId() {
71 | return id;
72 | }
73 |
74 | public void setSelected(boolean selected) {
75 | this.selected = selected;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/resource/model/OBJScene.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.resource.model;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceShaderProgram;
4 | import io.github.craftedcart.fluidui.util.UIColor;
5 | import org.lwjgl.opengl.GL11;
6 |
7 | import java.util.List;
8 | import java.util.Objects;
9 |
10 | /**
11 | * @author CraftedCart
12 | * Created on 10/10/2016 (DD/MM/YYYY)
13 | */
14 | public class OBJScene {
15 |
16 | private List objectList;
17 |
18 | public void setObjectList(List objectList) {
19 | this.objectList = objectList;
20 | }
21 |
22 | public void renderAll(ResourceShaderProgram shaderProgram, boolean setTexture) {
23 | for (OBJObject object : objectList) {
24 | for (OBJFacesByMaterial facesByMaterial : object.facesByMaterialList) {
25 | facesByMaterial.vbo.render(shaderProgram, setTexture);
26 | }
27 | }
28 | }
29 |
30 | public void renderAll(ResourceShaderProgram shaderProgram, boolean setTexture, UIColor color) {
31 | for (OBJObject object : objectList) {
32 | for (OBJFacesByMaterial facesByMaterial : object.facesByMaterialList) {
33 | facesByMaterial.vbo.render(shaderProgram, setTexture, color);
34 | }
35 | }
36 | }
37 |
38 | public void renderObjectByName(ResourceShaderProgram shaderProgram, boolean setTexture, String name) {
39 | for (OBJObject object : objectList) {
40 | if (Objects.equals(object.name, name)) {
41 | for (OBJFacesByMaterial facesByMaterial : object.facesByMaterialList) {
42 | facesByMaterial.vbo.render(shaderProgram, setTexture);
43 | }
44 |
45 | break;
46 | }
47 | }
48 | }
49 |
50 | public void renderObjectByName(ResourceShaderProgram shaderProgram, boolean setTexture, UIColor color, String name) {
51 | for (OBJObject object : objectList) {
52 | if (Objects.equals(object.name, name)) {
53 | for (OBJFacesByMaterial facesByMaterial : object.facesByMaterialList) {
54 | facesByMaterial.vbo.render(shaderProgram, setTexture, color);
55 | }
56 |
57 | break;
58 | }
59 | }
60 | }
61 |
62 | public void unloadAll() {
63 | for (OBJObject object : objectList) {
64 | for (OBJFacesByMaterial facesByMaterial : object.facesByMaterialList) {
65 | GL11.glDeleteTextures(facesByMaterial.vbo.getTextureId());
66 | facesByMaterial.vbo.destroy();
67 | }
68 | }
69 | }
70 |
71 | public List getObjectList() {
72 | return objectList;
73 | }
74 |
75 | public boolean hasObject(String name) {
76 | for (OBJObject object : objectList) {
77 | if (Objects.equals(object.name, name)) {
78 | return true;
79 | }
80 | }
81 |
82 | //No object with a matching name was found
83 | return false;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/KeyDisplay.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component;
2 |
3 | import craftedcart.smblevelworkshop.util.MathUtils;
4 | import io.github.craftedcart.fluidui.component.Label;
5 | import io.github.craftedcart.fluidui.component.ListBox;
6 | import io.github.craftedcart.fluidui.component.Panel;
7 | import io.github.craftedcart.fluidui.theme.UITheme;
8 | import io.github.craftedcart.fluidui.util.EnumHAlignment;
9 | import io.github.craftedcart.fluidui.util.EnumVAlignment;
10 | import io.github.craftedcart.fluidui.util.UIColor;
11 | import io.github.craftedcart.fluidui.util.UIUtils;
12 | import org.jetbrains.annotations.NotNull;
13 |
14 | /**
15 | * @author CraftedCart
16 | * Created on 21/12/2016 (DD/MM/YYYY)
17 | */
18 | public class KeyDisplay extends Panel {
19 |
20 | private String string;
21 | private Label label;
22 | private float timerPercent = -1; //-1 = Disable the timer
23 | private float flashTimerPercent = 1;
24 |
25 | public KeyDisplay(String string) {
26 | super();
27 |
28 | this.string = string;
29 | }
30 |
31 | @Override
32 | public void postInit() {
33 | super.postInit();
34 |
35 | label = new Label();
36 | label.setOnInitAction(() -> {
37 | label.setTopLeftPos(0, 0);
38 | label.setBottomRightPos(0, 0);
39 | label.setTopLeftAnchor(0, 0);
40 | label.setBottomRightAnchor(1, 1);
41 | label.setVerticalAlign(EnumVAlignment.centre);
42 | label.setHorizontalAlign(EnumHAlignment.right);
43 | label.setText(string);
44 | label.setFont(theme.headerFont);
45 | });
46 | addChildComponent("label", label);
47 | }
48 |
49 | @Override
50 | public void draw() {
51 | super.draw();
52 |
53 | if (flashTimerPercent > 0) {
54 | flashTimerPercent -= UIUtils.getDelta() * 4; //Lasts for 0.25 seconds
55 | flashTimerPercent = Math.max(flashTimerPercent, 0);
56 |
57 | label.setTextColor(MathUtils.lerpUIColor(UIColor.matWhite(), UIColor.matBlue(), flashTimerPercent).alpha(timerPercent == -1 ? 1 : timerPercent));
58 | }
59 |
60 | if (timerPercent != -1) {
61 | timerPercent -= UIUtils.getDelta(); //Last for 1 second
62 | label.setTextColor(label.textColor.alpha(timerPercent));
63 |
64 | if (timerPercent <= 0.0f) { //Self destruct!
65 | assert parentComponent instanceof ListBox;
66 | ((ListBox) parentComponent).removeChildComponent(name);
67 | }
68 | }
69 | }
70 |
71 | @Override
72 | public void setTheme(@NotNull UITheme theme) {
73 | super.setTheme(theme);
74 |
75 | backgroundColor = theme.panelBackgroundColor.alpha(0.25);
76 | }
77 |
78 | public void startTimer() {
79 | timerPercent = 1;
80 | }
81 |
82 | public void stopTimer() {
83 | timerPercent = -1;
84 | label.setTextColor(label.textColor.alpha(1));
85 | }
86 |
87 | public void flash() {
88 | flashTimerPercent = 1;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### JetBrains template
3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5 |
6 | # User-specific stuff:
7 | .idea/workspace.xml
8 | .idea/tasks.xml
9 | .idea/dictionaries
10 | .idea/vcs.xml
11 | .idea/jsLibraryMappings.xml
12 |
13 | # Sensitive or high-churn files:
14 | .idea/dataSources.ids
15 | .idea/dataSources.xml
16 | .idea/dataSources.local.xml
17 | .idea/sqlDataSources.xml
18 | .idea/dynamic.xml
19 | .idea/uiDesigner.xml
20 |
21 | # Gradle:
22 | .idea/gradle.xml
23 | .idea/libraries
24 |
25 | # Mongo Explorer plugin:
26 | .idea/mongoSettings.xml
27 |
28 | ## File-based project format:
29 | *.iws
30 |
31 | ## Plugin-specific files:
32 |
33 | # IntelliJ
34 | /out/
35 |
36 | # mpeltonen/sbt-idea plugin
37 | .idea_modules/
38 |
39 | # JIRA plugin
40 | atlassian-ide-plugin.xml
41 |
42 | # Crashlytics plugin (for Android Studio and IntelliJ)
43 | com_crashlytics_export_strings.xml
44 | crashlytics.properties
45 | crashlytics-build.properties
46 | fabric.properties
47 | ### Eclipse template
48 |
49 | .metadata
50 | bin/
51 | tmp/
52 | *.tmp
53 | *.bak
54 | *.swp
55 | *~.nib
56 | local.properties
57 | .settings/
58 | .loadpath
59 | .recommenders
60 |
61 | # Eclipse Core
62 | .project
63 |
64 | # External tool builders
65 | .externalToolBuilders/
66 |
67 | # Locally stored "Eclipse launch configurations"
68 | *.launch
69 |
70 | # PyDev specific (Python IDE for Eclipse)
71 | *.pydevproject
72 |
73 | # CDT-specific (C/C++ Development Tooling)
74 | .cproject
75 |
76 | # JDT-specific (Eclipse Java Development Tools)
77 | .classpath
78 |
79 | # Java annotation processor (APT)
80 | .factorypath
81 |
82 | # PDT-specific (PHP Development Tools)
83 | .buildpath
84 |
85 | # sbteclipse plugin
86 | .target
87 |
88 | # Tern plugin
89 | .tern-project
90 |
91 | # TeXlipse plugin
92 | .texlipse
93 |
94 | # STS (Spring Tool Suite)
95 | .springBeans
96 |
97 | # Code Recommenders
98 | .recommenders/
99 | ### Java template
100 | *.class
101 |
102 | # Mobile Tools for Java (J2ME)
103 | .mtj.tmp/
104 |
105 | # Package Files #
106 | *.jar
107 | *.war
108 | *.ear
109 |
110 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
111 | hs_err_pid*
112 |
113 | ### Gradle template
114 | .gradle
115 | build/
116 |
117 | # Ignore Gradle GUI config
118 | gradle-app.setting
119 |
120 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
121 | !gradle-wrapper.jar
122 |
123 | # Cache of project
124 | .gradletasknamecache
125 |
126 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
127 | # gradle/wrapper/gradle-wrapper.properties
128 |
129 | #FluidUI
130 | lib/FluidUI/build
131 | lib/FluidUI/.idea/gradle.xml
132 | lib/FluidUI/.idea/libraries
133 |
134 | #oObjLoader
135 | src/main/java/com/owens/oobjloader/lwjgl/DisplayTest.java
136 | src/main/java/com/owens/oobjloader/test/ParseTest.java
137 |
138 | #Mac
139 | .DS_Store
140 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/wormhole.mtl:
--------------------------------------------------------------------------------
1 | # Blender MTL File: 'None'
2 | # Material Count: 12
3 |
4 | newmtl MAT_NULL
5 | Ns 96.078431
6 | Ka 1.000000 1.000000 1.000000
7 | Kd 0.640000 0.640000 0.640000
8 | Ks 0.500000 0.500000 0.500000
9 | Ke 0.000000 0.000000 0.000000
10 | Ni 1.000000
11 | d 1.000000
12 | illum 2
13 | map_Kd WormSurface.exclude.png
14 |
15 | newmtl gxmat36
16 | Ns 96.078431
17 | Ka 1.000000 1.000000 1.000000
18 | Kd 0.640000 0.640000 0.640000
19 | Ks 0.500000 0.500000 0.500000
20 | Ke 0.000000 0.000000 0.000000
21 | Ni 1.000000
22 | d 1.000000
23 | illum 2
24 | map_Kd WormWood.exclude.png
25 |
26 | newmtl gxmat38
27 | Ns 96.078431
28 | Ka 1.000000 1.000000 1.000000
29 | Kd 0.640000 0.640000 0.640000
30 | Ks 0.500000 0.500000 0.500000
31 | Ke 0.000000 0.000000 0.000000
32 | Ni 1.000000
33 | d 1.000000
34 | illum 2
35 | map_Kd WormBlack.exclude.png
36 |
37 | newmtl gxmat40
38 | Ns 96.078431
39 | Ka 1.000000 1.000000 1.000000
40 | Kd 0.640000 0.640000 0.640000
41 | Ks 0.500000 0.500000 0.500000
42 | Ke 0.000000 0.000000 0.000000
43 | Ni 1.000000
44 | d 1.000000
45 | illum 2
46 | map_Kd WormBlack.exclude.png
47 |
48 | newmtl gxmat41
49 | Ns 96.078431
50 | Ka 1.000000 1.000000 1.000000
51 | Kd 0.640000 0.640000 0.640000
52 | Ks 0.500000 0.500000 0.500000
53 | Ke 0.000000 0.000000 0.000000
54 | Ni 1.000000
55 | d 1.000000
56 | illum 2
57 | map_Kd WormBlack.exclude.png
58 |
59 | newmtl gxmat44
60 | Ns 96.078431
61 | Ka 1.000000 1.000000 1.000000
62 | Kd 0.640000 0.640000 0.640000
63 | Ks 0.500000 0.500000 0.500000
64 | Ke 0.000000 0.000000 0.000000
65 | Ni 1.000000
66 | d 1.000000
67 | illum 2
68 | map_Kd WormWood.exclude.png
69 |
70 | newmtl gxmat47
71 | Ns 96.078431
72 | Ka 1.000000 1.000000 1.000000
73 | Kd 0.640000 0.640000 0.640000
74 | Ks 0.500000 0.500000 0.500000
75 | Ke 0.000000 0.000000 0.000000
76 | Ni 1.000000
77 | d 1.000000
78 | illum 2
79 | map_Kd WormWood.exclude.png
80 |
81 | newmtl gxmat49
82 | Ns 96.078431
83 | Ka 1.000000 1.000000 1.000000
84 | Kd 0.640000 0.640000 0.640000
85 | Ks 0.500000 0.500000 0.500000
86 | Ke 0.000000 0.000000 0.000000
87 | Ni 1.000000
88 | d 1.000000
89 | illum 2
90 | map_Kd WormWood.exclude.png
91 |
92 | newmtl gxmat51
93 | Ns 96.078431
94 | Ka 1.000000 1.000000 1.000000
95 | Kd 0.640000 0.640000 0.640000
96 | Ks 0.500000 0.500000 0.500000
97 | Ke 0.000000 0.000000 0.000000
98 | Ni 1.000000
99 | d 1.000000
100 | illum 2
101 | map_Kd WormBlack.exclude.png
102 |
103 | newmtl gxmat53
104 | Ns 96.078431
105 | Ka 1.000000 1.000000 1.000000
106 | Kd 0.640000 0.640000 0.640000
107 | Ks 0.500000 0.500000 0.500000
108 | Ke 0.000000 0.000000 0.000000
109 | Ni 1.000000
110 | d 1.000000
111 | illum 2
112 | map_Kd WormBlack.exclude.png
113 |
114 | newmtl gxmat55
115 | Ns 96.078431
116 | Ka 1.000000 1.000000 1.000000
117 | Kd 0.640000 0.640000 0.640000
118 | Ks 0.500000 0.500000 0.500000
119 | Ke 0.000000 0.000000 0.000000
120 | Ni 1.000000
121 | d 1.000000
122 | illum 2
123 | map_Kd WormWood.exclude.png
124 |
125 | newmtl gxmat57
126 | Ns 96.078431
127 | Ka 1.000000 1.000000 1.000000
128 | Kd 0.640000 0.640000 0.640000
129 | Ks 0.500000 0.500000 0.500000
130 | Ke 0.000000 0.000000 0.000000
131 | Ni 1.000000
132 | d 1.000000
133 | illum 2
134 | map_Kd WormBlack.exclude.png
135 |
--------------------------------------------------------------------------------
/.idea/modules/smblevelworkshop_main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/modules/smblevelworkshop_test.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/util/WSItemGroup.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.util;
2 |
3 | import craftedcart.smblevelworkshop.asset.Placeable;
4 | import io.github.craftedcart.fluidui.util.UIColor;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.jetbrains.annotations.Nullable;
7 |
8 | import java.util.*;
9 |
10 | /**
11 | * @author CraftedCart
12 | * Created on 11/04/2017 (DD/MM/YYYY)
13 | */
14 | public class WSItemGroup {
15 |
16 | @NotNull private UIColor color = UIColor.matGrey(); //Used in the UI
17 |
18 | @NotNull private Set objectNames = new HashSet<>();
19 | @NotNull private Map placeables = new HashMap<>();
20 | @NotNull private PosXYZ rotationCenter = new PosXYZ();
21 | @NotNull private PosXYZ initialRotation = new PosXYZ();
22 |
23 | public WSItemGroup() {}
24 |
25 | public WSItemGroup(@NotNull UIColor color) {
26 | this.color = color;
27 | }
28 |
29 | @NotNull
30 | public UIColor getColor() {
31 | return color;
32 | }
33 |
34 | public void setColor(@NotNull UIColor color) {
35 | this.color = color;
36 | }
37 |
38 | @NotNull
39 | public Map getPlaceables() {
40 | return placeables;
41 | }
42 |
43 | public boolean hasPlaceable(String name) {
44 | return placeables.containsKey(name);
45 | }
46 |
47 | public Placeable removePlaceable(String name) {
48 | return placeables.remove(name);
49 | }
50 |
51 | public Placeable replacePlaceable(String name, Placeable placeable) {
52 | return placeables.replace(name, placeable);
53 | }
54 |
55 | @Nullable
56 | public Placeable getPlaceable(String name) {
57 | return placeables.get(name);
58 | }
59 |
60 | public void clearPlaceables() {
61 | placeables.clear();
62 | }
63 |
64 | /**
65 | * Will be added to item group 0
66 | *
67 | * @param name The unique name for the placeable
68 | * @param placeable The placeable object to add
69 | * @return The name of the placeable
70 | */
71 | public String addPlaceable(String name, Placeable placeable) {
72 | placeables.put(name, placeable);
73 | return name;
74 | }
75 |
76 | @NotNull
77 | public PosXYZ getRotationCenter() {
78 | return rotationCenter;
79 | }
80 |
81 | public void setRotationCenter(@NotNull PosXYZ rotationCenter) {
82 | this.rotationCenter = rotationCenter;
83 | }
84 |
85 | @NotNull
86 | public PosXYZ getInitialRotation() {
87 | return initialRotation;
88 | }
89 |
90 | public void setInitialRotation(@NotNull PosXYZ initialRotation) {
91 | this.initialRotation = initialRotation;
92 | }
93 |
94 | public void addObject(String name) {
95 | objectNames.add(name);
96 | }
97 |
98 | public void addObjects(Collection collection) {
99 | objectNames.addAll(collection);
100 | }
101 |
102 | public void removeObject(String name) {
103 | objectNames.remove(name);
104 | }
105 |
106 | public void removeObjects(Collection collection) {
107 | objectNames.removeAll(collection);
108 | }
109 |
110 |
111 | public void clearObjects() {
112 | objectNames.clear();
113 | }
114 |
115 | @NotNull
116 | public Set getObjectNames() {
117 | return objectNames;
118 | }
119 |
120 | public boolean hasObject(String name) {
121 | return objectNames.contains(name);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/SMBLevelWorkshop.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop;
2 |
3 | import craftedcart.smblevelworkshop.project.ProjectManager;
4 | import craftedcart.smblevelworkshop.resource.ResourceManager;
5 | import craftedcart.smblevelworkshop.ui.DefaultUITheme;
6 | import craftedcart.smblevelworkshop.ui.LoadingScreen;
7 | import craftedcart.smblevelworkshop.ui.MainScreen;
8 | import craftedcart.smblevelworkshop.util.CrashHandler;
9 | import craftedcart.smblevelworkshop.util.LogHelper;
10 | import io.github.craftedcart.fluidui.FontCache;
11 | import org.lwjgl.LWJGLException;
12 | import org.lwjgl.input.Keyboard;
13 | import org.lwjgl.opengl.Display;
14 | import org.newdawn.slick.SlickException;
15 |
16 | import java.awt.*;
17 | import java.io.IOException;
18 |
19 | /**
20 | * @author CraftedCart
21 | * Created on 28/08/2016 (DD/MM/YYYY)
22 | */
23 | public class SMBLevelWorkshop {
24 |
25 | public static boolean shouldQuitJVM = true;
26 |
27 | public static void main(String[] args) {
28 | if (System.getProperty("os.name").toUpperCase().contains("LINUX")) {
29 | LogHelper.info(SMBLevelWorkshop.class, "Running on Linux - Calling XInitThreads()");
30 | System.loadLibrary("fixXInitThreads");
31 | }
32 |
33 | LogHelper.info(SMBLevelWorkshop.class, "SMB Level Workshop launched");
34 |
35 | Thread.setDefaultUncaughtExceptionHandler(CrashHandler.UNCAUGHT_EXCEPTION_HANDLER); //Set the uncaught exception handler (Create a crash report)
36 |
37 | try {
38 | Window.init();
39 | } catch (LWJGLException | FontFormatException | IOException e) {
40 | LogHelper.error(Window.class, LogHelper.stackTraceToString(e));
41 | }
42 | }
43 |
44 | public static void init() throws LWJGLException, IOException, FontFormatException, SlickException {
45 | Window.drawable.makeCurrent();
46 |
47 | FontCache.registerAWTFont("Roboto-Regular", SMBLevelWorkshop.class.getResourceAsStream("/Roboto-Regular.ttf"));
48 | FontCache.registerUnicodeFont("Roboto-Regular", 24);
49 | FontCache.registerUnicodeFont("Roboto-Regular", 16);
50 |
51 | Window.uiScreen = new LoadingScreen(); //Show the loading screen
52 |
53 | //Load resources
54 | LogHelper.info(SMBLevelWorkshop.class, "Loading resources");
55 | LoadingScreen.headerMessage = ResourceManager.initResources.getString("loadingResources"); //Set the loading screen's header message
56 | ResourceManager.queueVanillaResources();
57 | ResourceManager.registerAllResources();
58 |
59 | // LogHelper.info(SMBLevelWorkshop.class, "Initializing SoundSystem");
60 | // LoadingScreen.headerMessage = ResourceManager.initResources.getString("initSoundSystem");
61 | // LoadingScreen.infoMessage = "";
62 | // LoadingScreen.progress = -1;
63 | // try {
64 | // AudioUtils.init(); //Init audio stuff
65 | // } catch (SoundSystemException e) {
66 | // LogHelper.error(SMBLevelWorkshop.class, "Error while initializing AudioUtils\n" + CrashHandler.getStackTraceString(e));
67 | // }
68 |
69 | Keyboard.enableRepeatEvents(true);
70 |
71 | ProjectManager.setCurrentProject(new Project());
72 |
73 | MainScreen mainScreen = new MainScreen();
74 | mainScreen.setTheme(new DefaultUITheme());
75 | Window.setUIScreen(mainScreen);
76 | }
77 |
78 | public static void onQuit() {
79 | // AudioUtils.cleanup();
80 |
81 | if (Window.drawable != null) Display.destroy();
82 |
83 | if (shouldQuitJVM) {
84 | LogHelper.info(SMBLevelWorkshop.class, "Quitting JVM!");
85 | System.exit(0);
86 | }
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/InputOverlay.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component;
2 |
3 | import craftedcart.smblevelworkshop.Window;
4 | import craftedcart.smblevelworkshop.resource.LangManager;
5 | import io.github.craftedcart.fluidui.component.ListBox;
6 | import io.github.craftedcart.fluidui.component.Panel;
7 | import io.github.craftedcart.fluidui.util.UIColor;
8 | import org.lwjgl.input.Keyboard;
9 |
10 | import java.util.Objects;
11 |
12 | /**
13 | * @author CraftedCart
14 | * Created on 21/12/2016 (DD/MM/YYYY)
15 | */
16 | public class InputOverlay extends Panel {
17 |
18 | private ListBox modKeyListBox;
19 | private ListBox keyListBox;
20 |
21 | @Override
22 | public void postInit() {
23 | super.postInit();
24 |
25 | modKeyListBox = new ListBox();
26 | modKeyListBox.setOnInitAction(() -> {
27 | modKeyListBox.setTopLeftPos(-364, 4);
28 | modKeyListBox.setBottomRightPos(-184, 0);
29 | modKeyListBox.setTopLeftAnchor(1, 0);
30 | modKeyListBox.setBottomRightAnchor(1, 1);
31 | modKeyListBox.setCanScroll(false);
32 | modKeyListBox.setBackgroundColor(UIColor.transparent());
33 | });
34 | addChildComponent("modKeyListBox", modKeyListBox);
35 |
36 | keyListBox = new ListBox();
37 | keyListBox.setOnInitAction(() -> {
38 | keyListBox.setTopLeftPos(-180, 4);
39 | keyListBox.setBottomRightPos(-4, 0);
40 | keyListBox.setTopLeftAnchor(1, 0);
41 | keyListBox.setBottomRightAnchor(1, 1);
42 | keyListBox.setCanScroll(false);
43 | keyListBox.setBackgroundColor(UIColor.transparent());
44 | });
45 | addChildComponent("keyListBox", keyListBox);
46 | }
47 |
48 | public void onKeyDownManual(int key, char keyChar) {
49 | super.onKeyDown(key, keyChar);
50 |
51 | if (Window.isModifierKey(key)) {
52 | if (!modKeyListBox.childComponents.containsKey(Objects.toString(key))) {
53 | KeyDisplay kd = new KeyDisplay(LangManager.getItem(Keyboard.getKeyName(key)));
54 | kd.setOnInitAction(() -> {
55 | kd.setTopLeftPos(0, 0);
56 | kd.setBottomRightPos(0, 32);
57 | });
58 | modKeyListBox.addChildComponent(Objects.toString(key), kd);
59 | } else {
60 | ((KeyDisplay) modKeyListBox.childComponents.get(Objects.toString(key))).stopTimer();
61 | ((KeyDisplay) modKeyListBox.childComponents.get(Objects.toString(key))).flash();
62 | }
63 | } else {
64 | if (!keyListBox.childComponents.containsKey(Objects.toString(key))) {
65 | KeyDisplay kd = new KeyDisplay(LangManager.getItem(Keyboard.getKeyName(key)));
66 | kd.setOnInitAction(() -> {
67 | kd.setTopLeftPos(0, 0);
68 | kd.setBottomRightPos(0, 32);
69 | });
70 | keyListBox.addChildComponent(Objects.toString(key), kd);
71 | } else {
72 | ((KeyDisplay) keyListBox.childComponents.get(Objects.toString(key))).stopTimer();
73 | ((KeyDisplay) keyListBox.childComponents.get(Objects.toString(key))).flash();
74 | }
75 | }
76 | }
77 |
78 | public void onKeyReleasedManual(int key, char keyChar) {
79 | super.onKeyReleased(key, keyChar);
80 |
81 | if (Window.isModifierKey(key)) {
82 | if (modKeyListBox.childComponents.containsKey(Objects.toString(key))) {
83 | ((KeyDisplay) modKeyListBox.childComponents.get(Objects.toString(key))).startTimer();
84 | }
85 | } else {
86 | if (keyListBox.childComponents.containsKey(Objects.toString(key))) {
87 | ((KeyDisplay) keyListBox.childComponents.get(Objects.toString(key))).startTimer();
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/animation/BufferedAnimData.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.animation;
2 |
3 | import craftedcart.smblevelworkshop.util.MathUtils;
4 | import org.jetbrains.annotations.Nullable;
5 |
6 | import java.util.Map;
7 | import java.util.TreeMap;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 02/01/2017 (DD/MM/YYYY)
12 | */
13 | public class BufferedAnimData extends AnimData {
14 |
15 | protected float keyframeBufferTranslation = 0.0f;
16 | protected float keyframeBufferScale = 1.0f;
17 | protected float keyframeBufferScaleCenter = 0.0f;
18 |
19 | @Nullable protected Float snapToTranslation = null;
20 |
21 | public TreeMap getFramesBufferTransformed(TreeMap original) {
22 | TreeMap transformedMap = new TreeMap<>();
23 |
24 | float keyframeBufferTranslationSnapped = getSnappedTranslationValue(keyframeBufferTranslation);
25 |
26 | for (Map.Entry entry : original.entrySet()) {
27 | transformedMap.put(
28 | ((entry.getKey() + keyframeBufferTranslationSnapped + keyframeBufferScaleCenter) * keyframeBufferScale) - keyframeBufferScaleCenter,
29 | entry.getValue());
30 | }
31 |
32 | return transformedMap;
33 | }
34 |
35 | public TreeMap getPosXFramesTransformed() {
36 | return getFramesBufferTransformed(posXFrames);
37 | }
38 |
39 | public TreeMap getPosYFramesTransformed() {
40 | return getFramesBufferTransformed(posYFrames);
41 | }
42 |
43 | public TreeMap getPosZFramesTransformed() {
44 | return getFramesBufferTransformed(posZFrames);
45 | }
46 |
47 | public TreeMap getRotXFramesTransformed() {
48 | return getFramesBufferTransformed(rotXFrames);
49 | }
50 |
51 | public TreeMap getRotYFramesTransformed() {
52 | return getFramesBufferTransformed(rotYFrames);
53 | }
54 |
55 | public TreeMap getRotZFramesTransformed() {
56 | return getFramesBufferTransformed(rotZFrames);
57 | }
58 |
59 | public AnimData getTransformedAnimData() {
60 | AnimData ad = new AnimData();
61 |
62 | ad.setRotationCenter(rotationCenter);
63 |
64 | ad.posXFrames = getPosXFramesTransformed();
65 | ad.posYFrames = getPosYFramesTransformed();
66 | ad.posZFrames = getPosZFramesTransformed();
67 |
68 | ad.rotXFrames = getRotXFramesTransformed();
69 | ad.rotYFrames = getRotYFramesTransformed();
70 | ad.rotZFrames = getRotZFramesTransformed();
71 |
72 | return ad;
73 | }
74 |
75 | public float getKeyframeBufferTranslation() {
76 | return keyframeBufferTranslation;
77 | }
78 |
79 | public float getKeyframeBufferScale() {
80 | return keyframeBufferScale;
81 | }
82 |
83 | public float getKeyframeBufferScaleCenter() {
84 | return keyframeBufferScaleCenter;
85 | }
86 |
87 | public void setKeyframeBufferTranslation(float keyframeBufferTranslation) {
88 | this.keyframeBufferTranslation = keyframeBufferTranslation;
89 | }
90 |
91 | public void setKeyframeBufferScale(float keyframeBufferScale) {
92 | this.keyframeBufferScale = keyframeBufferScale;
93 | }
94 |
95 | public void setKeyframeBufferScaleCenter(float keyframeBufferScaleCenter) {
96 | this.keyframeBufferScaleCenter = keyframeBufferScaleCenter;
97 | }
98 |
99 | public void setSnapToTranslation(@Nullable Float snapToTranslation) {
100 | this.snapToTranslation = snapToTranslation;
101 | }
102 |
103 | public float getSnappedTranslationValue(float in) {
104 | if (snapToTranslation == null) {
105 | return in;
106 | } else {
107 | return MathUtils.snapTo(in, snapToTranslation);
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/src/main/resources/resources/vanilla/model/falloutVolume.obj:
--------------------------------------------------------------------------------
1 | # Blender v2.78 (sub 0) OBJ File: ''
2 | # www.blender.org
3 | mtllib falloutVolume.mtl
4 | o Cube_Cube.001
5 | v -0.500000 -0.480000 0.480000
6 | v -0.500000 0.480000 0.480000
7 | v -0.480000 -0.480000 -0.500000
8 | v -0.480000 0.480000 -0.500000
9 | v 0.500000 -0.480000 0.480000
10 | v 0.480000 0.500000 0.480000
11 | v 0.480000 -0.480000 -0.500000
12 | v 0.480000 0.480000 -0.500000
13 | v -0.500000 0.480000 -0.480000
14 | v -0.500000 -0.480000 -0.480000
15 | v 0.500000 -0.480000 -0.480000
16 | v 0.480000 0.500000 -0.480000
17 | v -0.480000 -0.500000 -0.480000
18 | v -0.480000 -0.480000 0.500000
19 | v -0.480000 0.500000 0.480000
20 | v -0.480000 0.500000 -0.480000
21 | v -0.480000 0.480000 0.500000
22 | v -0.500000 0.500000 -0.500000
23 | v 0.500000 0.480000 -0.480000
24 | v 0.500000 0.480000 0.480000
25 | v 0.500000 0.500000 -0.500000
26 | v 0.480000 -0.500000 -0.480000
27 | v 0.480000 -0.480000 0.500000
28 | v 0.480000 0.480000 0.500000
29 | v -0.480000 -0.500000 0.480000
30 | v -0.500000 0.500000 0.500000
31 | v 0.500000 0.500000 0.500000
32 | v 0.480000 -0.500000 0.480000
33 | v -0.500000 -0.500000 -0.500000
34 | v -0.500000 -0.500000 0.500000
35 | v 0.500000 -0.500000 -0.500000
36 | v 0.500000 -0.500000 0.500000
37 | v -0.500000 -0.480000 0.480000
38 | v -0.500000 0.480000 0.480000
39 | v -0.480000 -0.480000 -0.500000
40 | v -0.480000 0.480000 -0.500000
41 | v 0.500000 -0.480000 0.480000
42 | v 0.480000 0.500000 0.480000
43 | v 0.480000 -0.480000 -0.500000
44 | v 0.480000 0.480000 -0.500000
45 | v -0.500000 0.480000 -0.480000
46 | v -0.500000 -0.480000 -0.480000
47 | v 0.500000 -0.480000 -0.480000
48 | v 0.480000 0.500000 -0.480000
49 | v -0.480000 -0.500000 -0.480000
50 | v -0.480000 -0.480000 0.500000
51 | v -0.480000 0.500000 0.480000
52 | v -0.480000 0.500000 -0.480000
53 | v -0.480000 0.480000 0.500000
54 | v -0.500000 0.500000 -0.500000
55 | v 0.500000 0.480000 -0.480000
56 | v 0.500000 0.480000 0.480000
57 | v 0.500000 0.500000 -0.500000
58 | v 0.480000 -0.500000 -0.480000
59 | v 0.480000 -0.480000 0.500000
60 | v 0.480000 0.480000 0.500000
61 | v -0.480000 -0.500000 0.480000
62 | v -0.500000 0.500000 0.500000
63 | v 0.500000 0.500000 0.500000
64 | v 0.480000 -0.500000 0.480000
65 | v -0.500000 -0.500000 -0.500000
66 | v -0.500000 -0.500000 0.500000
67 | v 0.500000 -0.500000 -0.500000
68 | v 0.500000 -0.500000 0.500000
69 | vn 0.0000 0.0000 -1.0000
70 | vn -1.0000 0.0000 0.0000
71 | vn 0.0000 1.0000 0.0000
72 | vn 1.0000 0.0000 0.0000
73 | vn 0.0000 0.0000 1.0000
74 | vn 0.0000 -1.0000 0.0000
75 | usemtl MatMain
76 | s off
77 | f 4//1 3//1 29//1 18//1
78 | f 3//1 7//1 31//1 29//1
79 | f 8//1 4//1 18//1 21//1
80 | f 7//1 8//1 21//1 31//1
81 | f 1//2 10//2 29//2 30//2
82 | f 2//2 1//2 30//2 26//2
83 | f 9//2 2//2 26//2 18//2
84 | f 10//2 9//2 18//2 29//2
85 | f 15//3 16//3 18//3 26//3
86 | f 16//3 12//3 21//3 18//3
87 | f 12//3 6//3 27//3 21//3
88 | f 6//3 15//3 26//3 27//3
89 | f 19//4 11//4 31//4 21//4
90 | f 11//4 5//4 32//4 31//4
91 | f 20//4 19//4 21//4 27//4
92 | f 5//4 20//4 27//4 32//4
93 | f 14//5 17//5 26//5 30//5
94 | f 24//5 23//5 32//5 27//5
95 | f 23//5 14//5 30//5 32//5
96 | f 17//5 24//5 27//5 26//5
97 | f 13//6 25//6 30//6 29//6
98 | f 22//6 13//6 29//6 31//6
99 | f 28//6 22//6 31//6 32//6
100 | f 25//6 28//6 32//6 30//6
101 | f 36//5 50//5 61//5 35//5
102 | f 35//5 61//5 63//5 39//5
103 | f 40//5 53//5 50//5 36//5
104 | f 39//5 63//5 53//5 40//5
105 | f 33//4 62//4 61//4 42//4
106 | f 34//4 58//4 62//4 33//4
107 | f 41//4 50//4 58//4 34//4
108 | f 42//4 61//4 50//4 41//4
109 | f 47//6 58//6 50//6 48//6
110 | f 48//6 50//6 53//6 44//6
111 | f 44//6 53//6 59//6 38//6
112 | f 38//6 59//6 58//6 47//6
113 | f 51//2 53//2 63//2 43//2
114 | f 43//2 63//2 64//2 37//2
115 | f 52//2 59//2 53//2 51//2
116 | f 37//2 64//2 59//2 52//2
117 | f 46//1 62//1 58//1 49//1
118 | f 56//1 59//1 64//1 55//1
119 | f 55//1 64//1 62//1 46//1
120 | f 49//1 58//1 59//1 56//1
121 | f 45//3 61//3 62//3 57//3
122 | f 54//3 63//3 61//3 45//3
123 | f 60//3 64//3 63//3 54//3
124 | f 57//3 62//3 64//3 60//3
125 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/OutlinerObject.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component;
2 |
3 | import craftedcart.smblevelworkshop.Window;
4 | import craftedcart.smblevelworkshop.level.ClientLevelData;
5 | import craftedcart.smblevelworkshop.project.ProjectManager;
6 | import craftedcart.smblevelworkshop.resource.ResourceManager;
7 | import craftedcart.smblevelworkshop.resource.ResourceTexture;
8 | import craftedcart.smblevelworkshop.ui.DefaultUITheme;
9 | import io.github.craftedcart.fluidui.component.Button;
10 | import io.github.craftedcart.fluidui.component.Panel;
11 | import io.github.craftedcart.fluidui.component.TextButton;
12 | import io.github.craftedcart.fluidui.util.UIColor;
13 |
14 | /**
15 | * @author CraftedCart
16 | * Created on 14/10/2016 (DD/MM/YYYY)
17 | */
18 | public class OutlinerObject extends Panel {
19 |
20 | private String objectName;
21 |
22 | //UI
23 | private final TextButton objectButton = new TextButton();
24 | private final Button visibilityButton = new Button();
25 |
26 | //Textures
27 | private ResourceTexture visibiltyTex;
28 | private ResourceTexture visibiltyOffTex;
29 |
30 | public OutlinerObject(String objectName) {
31 | super();
32 |
33 | this.objectName = objectName;
34 |
35 | setTheme(new DefaultUITheme());
36 |
37 | visibiltyTex = ResourceManager.getTexture("image/visibility");
38 | visibiltyOffTex = ResourceManager.getTexture("image/visibilityOff");
39 |
40 | initComponents();
41 | }
42 |
43 | private void initComponents() {
44 | setName(objectName + "OutlinerObject");
45 | setBackgroundColor(UIColor.transparent());
46 |
47 | objectButton.setOnInitAction(() -> {
48 | objectButton.setTopLeftPos(0, 0);
49 | objectButton.setBottomRightPos(-22, 0);
50 | objectButton.setTopLeftAnchor(0, 0);
51 | objectButton.setBottomRightAnchor(1, 1);
52 | objectButton.setText(objectName);
53 | });
54 | objectButton.setOnLMBAction(() -> {
55 | assert ProjectManager.getCurrentClientLevelData() != null;
56 |
57 | if (Window.isShiftDown()) { //Toggle selection on shift
58 | ProjectManager.getCurrentClientLevelData().toggleSelectedObject(objectName);
59 | } else {
60 | ProjectManager.getCurrentClientLevelData().clearSelectedExternalBackgroundObjects();
61 | ProjectManager.getCurrentClientLevelData().clearSelectedObjects();
62 | ProjectManager.getCurrentClientLevelData().addSelectedObject(objectName);
63 | }
64 | });
65 | addChildComponent("objectButton", objectButton);
66 |
67 | visibilityButton.setOnInitAction(() -> {
68 | visibilityButton.setTopLeftPos(-20, 0);
69 | visibilityButton.setBottomRightPos(-2, 0);
70 | visibilityButton.setTopLeftAnchor(1, 0);
71 | visibilityButton.setBottomRightAnchor(1, 1);
72 | visibilityButton.setTexture(visibiltyTex.getTexture());
73 | });
74 | visibilityButton.setOnLMBAction(() -> {
75 | assert ProjectManager.getCurrentClientLevelData() != null;
76 |
77 | ClientLevelData cld = ProjectManager.getCurrentClientLevelData();
78 | assert cld != null;
79 | cld.toggleHiddenObject(objectName);
80 |
81 | if (cld.isObjectHidden(objectName)) {
82 | visibilityButton.setTexture(visibiltyOffTex.getTexture());
83 | } else {
84 | visibilityButton.setTexture(visibiltyTex.getTexture());
85 | }
86 |
87 | });
88 | addChildComponent("visibilityButton", visibilityButton);
89 | }
90 |
91 | public void setObjectName(String objectName) {
92 | this.objectName = objectName;
93 | setName(objectName + "OutlinerObject");
94 | }
95 |
96 | public String getObjectName() {
97 | return objectName;
98 | }
99 |
100 | public void setButtonColor(UIColor color) {
101 | objectButton.setBackgroundIdleColor(color);
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/DialogOverlayUIScreen.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import craftedcart.smblevelworkshop.resource.LangManager;
4 | import io.github.craftedcart.fluidui.FluidUIScreen;
5 | import io.github.craftedcart.fluidui.FontCache;
6 | import io.github.craftedcart.fluidui.component.Label;
7 | import io.github.craftedcart.fluidui.component.Panel;
8 | import io.github.craftedcart.fluidui.component.TextButton;
9 | import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor;
10 | import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor;
11 | import io.github.craftedcart.fluidui.util.UIColor;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 24/09/2016 (DD/MM/YYYY)
16 | */
17 | public class DialogOverlayUIScreen extends FluidUIScreen {
18 |
19 | public DialogOverlayUIScreen(String title, String message) {
20 | init(title, message);
21 | }
22 |
23 | private void init(String title, String message) {
24 |
25 | final Panel backgroundPanel = new Panel();
26 | backgroundPanel.setOnInitAction(() -> {
27 | backgroundPanel.setTheme(new DialogUITheme());
28 |
29 | backgroundPanel.setTopLeftPos(0, 0);
30 | backgroundPanel.setBottomRightPos(0, 0);
31 | backgroundPanel.setTopLeftAnchor(0, 0);
32 | backgroundPanel.setBottomRightAnchor(1, 1);
33 | backgroundPanel.setBackgroundColor(UIColor.pureBlack(0));
34 |
35 |
36 | PluginSmoothAnimatePanelBackgroundColor backgroundPanelAnimColor = new PluginSmoothAnimatePanelBackgroundColor();
37 | backgroundPanelAnimColor.setTargetBackgroundColor(UIColor.pureBlack(0.75));
38 | backgroundPanel.addPlugin(backgroundPanelAnimColor);
39 | });
40 | addChildComponent("backgroundPanel", backgroundPanel);
41 |
42 | final Panel mainPanel = new Panel();
43 | mainPanel.setOnInitAction(() -> {
44 | mainPanel.setTopLeftPos(-256, -128);
45 | mainPanel.setBottomRightPos(256, 128);
46 | mainPanel.setTopLeftAnchor(0.5, 1.5);
47 | mainPanel.setBottomRightAnchor(0.5, 1.5);
48 |
49 | PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor();
50 | mainPanelAnimAnchor.setTargetTopLeftAnchor(0.5, 0.5);
51 | mainPanelAnimAnchor.setTargetBottomRightAnchor(0.5, 0.5);
52 | mainPanel.addPlugin(mainPanelAnimAnchor);
53 | });
54 | backgroundPanel.addChildComponent("mainPanel", mainPanel);
55 |
56 | final Label titleLabel = new Label();
57 | titleLabel.setOnInitAction(() -> {
58 | titleLabel.setTopLeftPos(24, 24);
59 | titleLabel.setBottomRightPos(-24, 72);
60 | titleLabel.setTopLeftAnchor(0, 0);
61 | titleLabel.setBottomRightAnchor(1, 0);
62 | titleLabel.setTextColor(UIColor.matGrey900());
63 | titleLabel.setText(title);
64 | titleLabel.setFont(FontCache.getUnicodeFont("Roboto-Regular", 24));
65 | });
66 | mainPanel.addChildComponent("titleLabel", titleLabel);
67 |
68 | final Label label = new Label();
69 | label.setOnInitAction(() -> {
70 | label.setTopLeftPos(24, 72);
71 | label.setBottomRightPos(-24, -72);
72 | label.setTopLeftAnchor(0, 0);
73 | label.setBottomRightAnchor(1, 1);
74 | label.setTextColor(UIColor.matGrey900());
75 | label.setText(message);
76 | });
77 | mainPanel.addChildComponent("label", label);
78 |
79 | final TextButton okButton = new TextButton();
80 | okButton.setOnInitAction(() -> {
81 | okButton.setTopLeftPos(-152, -48);
82 | okButton.setBottomRightPos(-24, -24);
83 | okButton.setTopLeftAnchor(1, 1);
84 | okButton.setBottomRightAnchor(1, 1);
85 | okButton.setText(LangManager.getItem("ok"));
86 | });
87 | okButton.setOnLMBAction(() -> {
88 | assert parentComponent instanceof FluidUIScreen;
89 | ((FluidUIScreen) parentComponent).setOverlayUiScreen(null); //Hide on OK
90 | });
91 | mainPanel.addChildComponent("okButton", okButton);
92 |
93 | }
94 |
95 | }
96 |
97 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/component/transform/XYZKeyframeButtons.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui.component.transform;
2 |
3 | import craftedcart.smblevelworkshop.resource.ResourceManager;
4 | import craftedcart.smblevelworkshop.ui.DefaultUITheme;
5 | import craftedcart.smblevelworkshop.util.EnumAxis;
6 | import io.github.craftedcart.fluidui.component.Button;
7 | import io.github.craftedcart.fluidui.component.ListBox;
8 | import io.github.craftedcart.fluidui.component.Panel;
9 | import io.github.craftedcart.fluidui.uiaction.UIAction1;
10 | import io.github.craftedcart.fluidui.util.UIColor;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | /**
14 | * @author CraftedCart
15 | * Created on 30/10/2016 (DD/MM/YYYY)
16 | */
17 | public class XYZKeyframeButtons extends Panel {
18 |
19 | private ListBox listBox;
20 |
21 | private Button xButton;
22 | private Button yButton;
23 | private Button zButton;
24 |
25 | @Nullable private UIAction1 onKeyframeActivatedAction;
26 |
27 | public XYZKeyframeButtons() {
28 | init();
29 | postInit();
30 | }
31 |
32 | public void init() {
33 | super.init();
34 |
35 | setTheme(new DefaultUITheme());
36 |
37 | listBox = new ListBox();
38 | xButton = new Button();
39 | yButton = new Button();
40 | zButton = new Button();
41 |
42 | setBackgroundColor(UIColor.transparent());
43 | listBox.setUseStencil(false);
44 |
45 | listBox.setOnInitAction(() -> {
46 | listBox.setTopLeftPos(0, 0);
47 | listBox.setBottomRightPos(0, 0);
48 | listBox.setTopLeftAnchor(0, 0);
49 | listBox.setBottomRightAnchor(1, 1);
50 | listBox.setBackgroundColor(UIColor.transparent());
51 | listBox.setCanScroll(false);
52 | listBox.scrollbarThickness = 0;
53 | });
54 | addChildComponent("listBox", listBox);
55 |
56 | //
57 | //Defined at class level
58 | xButton.setOnInitAction(() -> {
59 | xButton.setTexture(ResourceManager.getTexture("image/keyframe").getTexture());
60 | xButton.setTopLeftPos(0, 0);
61 | xButton.setBottomRightPos(0, 24);
62 | });
63 | xButton.setOnLMBAction(() -> onKeyframeActivated(EnumAxis.X));
64 | listBox.addChildComponent("xButton", xButton);
65 | //
66 |
67 | //
68 | //Defined at class level
69 | yButton.setOnInitAction(() -> {
70 | yButton.setTexture(ResourceManager.getTexture("image/keyframe").getTexture());
71 | yButton.setTopLeftPos(0, 0);
72 | yButton.setBottomRightPos(0, 24);
73 | });
74 | yButton.setOnLMBAction(() -> onKeyframeActivated(EnumAxis.Y));
75 | listBox.addChildComponent("yButton", yButton);
76 | //
77 |
78 | //
79 | //Defined at class level
80 | zButton.setOnInitAction(() -> {
81 | zButton.setTexture(ResourceManager.getTexture("image/keyframe").getTexture());
82 | zButton.setTopLeftPos(0, 0);
83 | zButton.setBottomRightPos(0, 24);
84 | });
85 | zButton.setOnLMBAction(() -> onKeyframeActivated(EnumAxis.Z));
86 | listBox.addChildComponent("zButton", zButton);
87 | //
88 | }
89 |
90 | public void setXEnabled(boolean enabled) {
91 | xButton.setEnabled(enabled);
92 | }
93 |
94 | public void setYEnabled(boolean enabled) {
95 | yButton.setEnabled(enabled);
96 | }
97 |
98 | public void setZEnabled(boolean enabled) {
99 | zButton.setEnabled(enabled);
100 | }
101 |
102 | private void onKeyframeActivated(EnumAxis axis) {
103 | if (onKeyframeActivatedAction != null) {
104 | onKeyframeActivatedAction.execute(axis);
105 | }
106 | }
107 |
108 | public void setOnKeyframeActivatedAction(@Nullable UIAction1 onKeyframeActivatedAction) {
109 | this.onKeyframeActivatedAction = onKeyframeActivatedAction;
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/parser/BuilderInterface.java:
--------------------------------------------------------------------------------
1 | package com.owens.oobjloader.parser;
2 |
3 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
4 | // and is released to the public domain. Share and enjoy. Since some
5 | // people argue that it is impossible to release software to the public
6 | // domain, you are also free to use this code under any version of the
7 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
8 | // license. (I generally don't care so I'll almost certainly say yes.)
9 | // In addition this code may also be used under the "unlicense" described
10 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
11 |
12 | public interface BuilderInterface {
13 |
14 | public final int NO_SMOOTHING_GROUP = 0;
15 | public final int EMPTY_VERTEX_VALUE = Integer.MIN_VALUE;
16 | public final int MTL_KA = 0;
17 | public final int MTL_KD = 1;
18 | public final int MTL_KS = 2;
19 | public final int MTL_TF = 3;
20 | public final int MTL_MAP_KA = 0;
21 | public final int MTL_MAP_KD = 1;
22 | public final int MTL_MAP_KS = 2;
23 | public final int MTL_MAP_NS = 3;
24 | public final int MTL_MAP_D = 4;
25 | public final int MTL_DECAL = 5;
26 | public final int MTL_DISP = 6;
27 | public final int MTL_BUMP = 7;
28 | public final int MTL_REFL_TYPE_UNKNOWN = -1;
29 | public final int MTL_REFL_TYPE_SPHERE = 0;
30 | public final int MTL_REFL_TYPE_CUBE_TOP = 1;
31 | public final int MTL_REFL_TYPE_CUBE_BOTTOM = 2;
32 | public final int MTL_REFL_TYPE_CUBE_FRONT = 3;
33 | public final int MTL_REFL_TYPE_CUBE_BACK = 4;
34 | public final int MTL_REFL_TYPE_CUBE_LEFT = 5;
35 | public final int MTL_REFL_TYPE_CUBE_RIGHT = 6;
36 |
37 | public void setObjFilename(String filename);
38 |
39 | public void addVertexGeometric(float x, float y, float z);
40 |
41 | public void addVertexTexture(float u, float v);
42 |
43 | public void addVertexNormal(float x, float y, float z);
44 |
45 | public void addPoints(int values[]);
46 |
47 | public void addLine(int values[]);
48 |
49 | // The param for addFace is an array of vertex indices. This array should have a length that is a multiple of 3.
50 | //
51 | // For each triplet of values;
52 | //
53 | // The first value is an absolute or relative index to a geometric vertex. (VertexGeometric)
54 | // The second value is an absolute or relative index to a vertex texture coordinate. (VertexTexture)
55 | // The third vertex is an absolute or relative index to a vertex normal. (VertexNormal)
56 | //
57 | // The indices for the texture and normal MAY be empty in which case they will be set equal to the special
58 | // value defined in BuilderInterface, EMPTY_VERTEX_VALUE.
59 | //
60 | // Absolute indices are positive values that specify a vertex/texture/normal by it's absolute position within the OBJ file.
61 | //
62 | // Relative indices are negative values that specify a vertex/texture/normal by it's position relative to the line the index
63 | // is on, i.e. a line specifying a face (triangle) may specify an geometry vertex as -5 which means the 5 most recently seen
64 | // geometry vertex.
65 | public void addFace(int vertexIndices[]);
66 |
67 | public void addObjectName(String name);
68 |
69 | public void addMapLib(String[] names);
70 |
71 | public void setCurrentGroupNames(String[] names);
72 |
73 | public void setCurrentSmoothingGroup(int groupNumber);
74 |
75 | public void setCurrentUseMap(String name);
76 |
77 | public void setCurrentUseMaterial(String name);
78 |
79 | public void newMtl(String name);
80 |
81 | public void setXYZ(int type, float x, float y, float z);
82 |
83 | public void setRGB(int type, float r, float g, float b);
84 |
85 | public void setIllum(int illumModel);
86 |
87 | public void setD(boolean halo, float factor);
88 |
89 | public void setNs(float exponent);
90 |
91 | public void setSharpness(float value);
92 |
93 | public void setNi(float opticalDensity);
94 |
95 | public void setMapDecalDispBump(int type, String filename);
96 |
97 | public void setRefl(int type, String filename);
98 |
99 | public void doneParsingMaterial();
100 |
101 | public void doneParsingObj(String filename);
102 | }
--------------------------------------------------------------------------------
/src/main/java/com/owens/oobjloader/lwjgl/TextureLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this template, choose Tools | Templates
3 | * and open the template in the editor.
4 | */
5 | package com.owens.oobjloader.lwjgl;
6 |
7 | // This code was written by myself, Sean R. Owens, sean at guild dot net,
8 | // and is released to the public domain. Share and enjoy. Since some
9 | // people argue that it is impossible to release software to the public
10 | // domain, you are also free to use this code under any version of the
11 | // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another
12 | // license. (I generally don't care so I'll almost certainly say yes.)
13 | // In addition this code may also be used under the "unlicense" described
14 | // at http://unlicense.org/ . See the file UNLICENSE in the repo.
15 |
16 | import org.lwjgl.BufferUtils;
17 | import org.lwjgl.opengl.GL11;
18 | import org.lwjgl.opengl.GL12;
19 |
20 | import javax.imageio.ImageIO;
21 | import java.awt.image.BufferedImage;
22 | import java.awt.image.PixelGrabber;
23 | import java.io.File;
24 | import java.io.IOException;
25 | import java.nio.ByteBuffer;
26 | import java.nio.ByteOrder;
27 | import java.nio.IntBuffer;
28 | import java.util.HashMap;
29 | import java.util.logging.Logger;
30 |
31 | import static java.util.logging.Level.SEVERE;
32 |
33 | /**
34 | *
35 | * @author sean
36 | */
37 | public class TextureLoader {
38 | private Logger log = Logger.getLogger(TextureLoader.class.getName());
39 |
40 | private final static int TEXTURE_LEVEL = 0;
41 | private HashMap loadedTextures = new HashMap();
42 |
43 | public int convertToTexture(BufferedImage img) {
44 | int[] pixels = new int[img.getWidth() * img.getHeight()];
45 | PixelGrabber grabber = new PixelGrabber(img, 0, 0, img.getWidth(), img.getHeight(), pixels, 0, img.getWidth());
46 | try {
47 | grabber.grabPixels();
48 | } catch (InterruptedException e) {
49 | log.log(SEVERE, "InterruptedException while trying to grab pixels, e=" + e);
50 | e.printStackTrace();
51 | return -1;
52 | }
53 |
54 | int bufLen = 0;
55 | bufLen = pixels.length * 4;
56 |
57 | ByteBuffer oglPixelBuf = BufferUtils.createByteBuffer(bufLen);
58 |
59 | for (int y = img.getHeight() - 1; y >= 0; y--) {
60 | for (int x = 0; x < img.getWidth(); x++) {
61 | int pixel = pixels[y * img.getWidth() + x];
62 | oglPixelBuf.put((byte) ((pixel >> 16) & 0xFF));
63 | oglPixelBuf.put((byte) ((pixel >> 8) & 0xFF));
64 | oglPixelBuf.put((byte) ((pixel >> 0) & 0xFF));
65 | oglPixelBuf.put((byte) ((pixel >> 24) & 0xFF));
66 | }
67 | }
68 |
69 | oglPixelBuf.flip();
70 |
71 | ByteBuffer temp = ByteBuffer.allocateDirect(4);
72 | temp.order(ByteOrder.nativeOrder());
73 | IntBuffer textBuf = temp.asIntBuffer();
74 | GL11.glGenTextures(textBuf);
75 | int textureID = textBuf.get(0);
76 |
77 | GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
78 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
79 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
80 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
81 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
82 | GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
83 |
84 | GL11.glTexImage2D(GL11.GL_TEXTURE_2D,
85 | TEXTURE_LEVEL,
86 | GL11.GL_RGBA8,
87 | img.getWidth(),
88 | img.getHeight(),
89 | 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
90 | oglPixelBuf);
91 |
92 | return textureID;
93 | }
94 |
95 | public int load(String filename) throws IOException {
96 | if (loadedTextures.containsKey(filename)) {
97 | return loadedTextures.get(filename);
98 | }
99 |
100 | File imageFile = new File(filename);
101 |
102 | if (!imageFile.exists()) {
103 | log.log(SEVERE, "FIle " + filename + " does not exist");
104 | return 0;
105 | }
106 | if (!imageFile.canRead()) {
107 | log.log(SEVERE, "FIle " + filename + " is not readable");
108 | return 0;
109 | }
110 |
111 | BufferedImage img = null;
112 | img = ImageIO.read(imageFile);
113 | return convertToTexture(img);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.asset;
2 |
3 | import craftedcart.smblevelworkshop.util.ITransformable;
4 | import craftedcart.smblevelworkshop.util.LogHelper;
5 | import craftedcart.smblevelworkshop.util.PosXYZ;
6 | import craftedcart.smbworkshopexporter.placeables.*;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | /**
10 | * @author CraftedCart
11 | * Created on 10/09/2016 (DD/MM/YYYY)
12 | */
13 | public class Placeable implements Cloneable, ITransformable {
14 |
15 | @NotNull private IAsset asset;
16 |
17 | @NotNull private PosXYZ position = new PosXYZ();
18 | @NotNull private PosXYZ rotation = new PosXYZ();
19 | @NotNull private PosXYZ scale = new PosXYZ(1, 1, 1);
20 |
21 | public Placeable(@NotNull IAsset asset) {
22 | this.asset = asset;
23 | }
24 |
25 | public Placeable(@NotNull Goal goal) {
26 | asset = new AssetGoal();
27 | position = new PosXYZ(goal.pos);
28 | rotation = new PosXYZ(goal.rot);
29 |
30 | String type;
31 | switch (goal.type) {
32 | case BLUE:
33 | type = "blueGoal";
34 | break;
35 | case GREEN:
36 | type = "greenGoal";
37 | break;
38 | case RED:
39 | type = "redGoal";
40 | break;
41 | default:
42 | //This shouldn't happen! Default to blue
43 | type = "blueGoal";
44 | }
45 |
46 | asset.setType(type);
47 | }
48 |
49 | public Placeable(@NotNull Bumper bumper) {
50 | asset = new AssetBumper();
51 | position = new PosXYZ(bumper.pos);
52 | rotation = new PosXYZ(bumper.rot);
53 | scale = new PosXYZ(bumper.scl);
54 | }
55 |
56 | public Placeable(@NotNull Jamabar jamabar) {
57 | asset = new AssetJamabar();
58 | position = new PosXYZ(jamabar.pos);
59 | rotation = new PosXYZ(jamabar.rot);
60 | scale = new PosXYZ(jamabar.scl);
61 | }
62 |
63 | public Placeable(@NotNull Banana banana) {
64 | asset = new AssetBanana();
65 | position = new PosXYZ(banana.pos);
66 |
67 | String type;
68 | switch (banana.type) {
69 | case SINGLE:
70 | type = "singleBanana";
71 | break;
72 | case BUNCH:
73 | type = "bunchBanana";
74 | break;
75 | default:
76 | //This shouldn't happen! Default to single
77 | type = "singleBanana";
78 | }
79 |
80 | asset.setType(type);
81 | }
82 |
83 | public Placeable(@NotNull Wormhole wormhole) {
84 | AssetWormhole aWormhole = new AssetWormhole();
85 | asset = aWormhole;
86 | position = new PosXYZ(wormhole.pos);
87 | rotation = new PosXYZ(wormhole.rot);
88 | aWormhole.setDestinationName(wormhole.destinationName);
89 | }
90 |
91 | public void setAsset(@NotNull IAsset asset) {
92 | this.asset = asset;
93 | }
94 |
95 | @NotNull
96 | public IAsset getAsset() {
97 | return asset;
98 | }
99 |
100 | public void setPosition(@NotNull PosXYZ position) {
101 | this.position = position;
102 | }
103 |
104 | @NotNull
105 | public PosXYZ getPosition() {
106 | return position;
107 | }
108 |
109 | @Override
110 | public boolean canMoveX() {
111 | return getAsset().canGrabX();
112 | }
113 |
114 | @Override
115 | public boolean canMoveY() {
116 | return getAsset().canGrabY();
117 | }
118 |
119 | @Override
120 | public boolean canMoveZ() {
121 | return getAsset().canGrabZ();
122 | }
123 |
124 | @Override
125 | public boolean canRotate() {
126 | return getAsset().canRotate();
127 | }
128 |
129 | @Override
130 | public boolean canScale() {
131 | return getAsset().canScale();
132 | }
133 |
134 | public void setRotation(@NotNull PosXYZ rotation) {
135 | this.rotation = rotation;
136 | }
137 |
138 | @NotNull
139 | public PosXYZ getRotation() {
140 | return rotation;
141 | }
142 |
143 | public void setScale(@NotNull PosXYZ scale) {
144 | this.scale = scale;
145 | }
146 |
147 | @NotNull
148 | public PosXYZ getScale() {
149 | return scale;
150 | }
151 |
152 | public Placeable getCopy() {
153 | try {
154 | IAsset newAsset = asset.getCopy();
155 | Placeable newPlaceable = (Placeable) clone();
156 | newPlaceable.setAsset(newAsset);
157 | return newPlaceable;
158 | } catch (CloneNotSupportedException e) {
159 | LogHelper.error(getClass(), "Failed to clone Placeable");
160 | LogHelper.error(getClass(), e);
161 | return null;
162 | }
163 | }
164 |
165 | }
166 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/ItemGroupSelectorOverlayScreen.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import craftedcart.smblevelworkshop.project.ProjectManager;
4 | import craftedcart.smblevelworkshop.resource.LangManager;
5 | import craftedcart.smblevelworkshop.resource.ResourceManager;
6 | import craftedcart.smblevelworkshop.util.WSItemGroup;
7 | import io.github.craftedcart.fluidui.FluidUIScreen;
8 | import io.github.craftedcart.fluidui.component.*;
9 | import io.github.craftedcart.fluidui.util.UIColor;
10 |
11 | import java.util.Map;
12 | import java.util.Objects;
13 |
14 | /**
15 | * @author CraftedCart
16 | * Created on 16/04/2017 (DD/MM/YYYY)
17 | */
18 | public class ItemGroupSelectorOverlayScreen extends FluidUIScreen {
19 |
20 | public ItemGroupSelectorOverlayScreen(double mousePercentY, Map itemGroupMap) {
21 | init(mousePercentY, itemGroupMap);
22 | }
23 |
24 | private void init(double mousePercentY, Map itemGroupMap) {
25 | setTheme(new DialogUITheme());
26 |
27 | final ListBox listBox = new ListBox();
28 | listBox.setOnInitAction(() -> {
29 | listBox.setTopLeftPos(-256, -38);
30 | listBox.setBottomRightPos(0, 0);
31 | listBox.setTopLeftAnchor(1, mousePercentY);
32 | listBox.setBottomRightAnchor(1, 1);
33 | });
34 | addChildComponent("listBox", listBox);
35 |
36 | //Add item group manager button
37 | final TextButton igmButton = new TextButton();
38 | igmButton.setOnInitAction(() -> {
39 | igmButton.setText(LangManager.getItem("itemGroupManager"));
40 | igmButton.setTopLeftPos(0, 0);
41 | igmButton.setBottomRightPos(0, 24);
42 | });
43 | igmButton.setOnLMBAction(() -> {
44 | assert parentComponent instanceof FluidUIScreen;
45 | FluidUIScreen uiScreen = (FluidUIScreen) parentComponent;
46 | uiScreen.setOverlayUiScreen(new ManageItemGroupsOverlayUIScreen()); //Replace ItemGroupSelectorOverlayScreen with item group manager
47 | });
48 | listBox.addChildComponent("itemGroupManagerButton", igmButton);
49 |
50 | for (Map.Entry entry : itemGroupMap.entrySet()) {
51 | // final TextButton button = new TextButton();
52 | // button.setOnInitAction(() -> {
53 | // button.setText(LangManager.getItem(entry.getKey()));
54 | // button.setTopLeftPos(0, 0);
55 | // button.setBottomRightPos(0, 24);
56 | // });
57 | final Button button = getItemGroup(entry.getKey(), entry.getValue());
58 | button.setOnLMBAction(() -> selectItemGroup(entry));
59 | if (Objects.equals(entry.getKey(), "STAGE_RESERVED") ||
60 | (Objects.equals(entry.getKey(), "BACKGROUND_RESERVED") && ProjectManager.getCurrentClientLevelData().getSelectedObjects().size() == 0)) {
61 | button.setEnabled(false);
62 | }
63 | listBox.addChildComponent(entry.getKey() + "TypeButton", button);
64 | }
65 |
66 | }
67 |
68 | private void selectItemGroup(Map.Entry entry) {
69 | assert parentComponent instanceof MainScreen;
70 |
71 | MainScreen mainScreen = (MainScreen) parentComponent;
72 | mainScreen.setItemGroupForSelectedPlaceables(entry.getKey());
73 | mainScreen.setItemGroupForSelectedObjects(entry.getKey());
74 |
75 | mainScreen.setOverlayUiScreen(null);
76 | }
77 |
78 | private Button getItemGroup(String name, WSItemGroup itemGroup) {
79 | UIColor col = itemGroup.getColor();
80 |
81 | final Button igButton = new Button();
82 | igButton.setOnInitAction(() -> {
83 | igButton.setTopLeftPos(0, 0);
84 | igButton.setBottomRightPos(0, 24);
85 | igButton.setBackgroundIdleColor(col.alpha(0.25));
86 |
87 | final Image colorImage = new Image();
88 | colorImage.setOnInitAction(() -> {
89 | colorImage.setTopLeftPos(0, 0);
90 | colorImage.setBottomRightPos(24, 0);
91 | colorImage.setTopLeftAnchor(0, 0);
92 | colorImage.setBottomRightAnchor(0, 1);
93 | colorImage.setTexture(ResourceManager.getTexture("image/circle").getTexture());
94 | colorImage.setColor(col);
95 | });
96 | igButton.addChildComponent("colorImage", colorImage);
97 |
98 | final Label igLabel = new Label();
99 | igLabel.setOnInitAction(() -> {
100 | igLabel.setTopLeftPos(28, 0);
101 | igLabel.setBottomRightPos(0, 0);
102 | igLabel.setTopLeftAnchor(0, 0);
103 | igLabel.setBottomRightAnchor(1, 1);
104 | igLabel.setText(name);
105 | });
106 | igButton.addChildComponent("igLabel", igLabel);
107 | });
108 |
109 | return igButton;
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/craftedcart/smblevelworkshop/ui/ColorPickerOverlayUIScreen.java:
--------------------------------------------------------------------------------
1 | package craftedcart.smblevelworkshop.ui;
2 |
3 | import craftedcart.smblevelworkshop.resource.LangManager;
4 | import io.github.craftedcart.fluidui.FluidUIScreen;
5 | import io.github.craftedcart.fluidui.component.Button;
6 | import io.github.craftedcart.fluidui.component.Panel;
7 | import io.github.craftedcart.fluidui.component.TextButton;
8 | import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor;
9 | import io.github.craftedcart.fluidui.uiaction.UIAction1;
10 | import io.github.craftedcart.fluidui.util.AnchorPoint;
11 | import io.github.craftedcart.fluidui.util.PosXY;
12 | import io.github.craftedcart.fluidui.util.UIColor;
13 | import org.lwjgl.opengl.Display;
14 |
15 | /**
16 | * @author CraftedCart
17 | * Created on 17/04/2017 (DD/MM/YYYY)
18 | */
19 | public class ColorPickerOverlayUIScreen extends FluidUIScreen {
20 |
21 | private UIAction1 callback;
22 |
23 | public ColorPickerOverlayUIScreen(PosXY mousePos, UIColor initialColor, UIAction1 callback) {
24 | this.callback = callback;
25 | init(mousePos, initialColor);
26 | }
27 |
28 | private void init(PosXY mousePos, UIColor initialColor) {
29 | AnchorPoint mousePercent = new AnchorPoint(
30 | mousePos.x / Display.getWidth(),
31 | mousePos.y / Display.getHeight()
32 | );
33 |
34 | final Panel backgroundPanel = new Panel();
35 | backgroundPanel.setOnInitAction(() -> {
36 | backgroundPanel.setTheme(new DialogUITheme());
37 |
38 | backgroundPanel.setTopLeftPos(0, 0);
39 | backgroundPanel.setBottomRightPos(0, 0);
40 | backgroundPanel.setTopLeftAnchor(0, 0);
41 | backgroundPanel.setBottomRightAnchor(1, 1);
42 | backgroundPanel.setBackgroundColor(UIColor.pureBlack(0));
43 |
44 |
45 | PluginSmoothAnimatePanelBackgroundColor backgroundPanelAnimColor = new PluginSmoothAnimatePanelBackgroundColor();
46 | backgroundPanelAnimColor.setTargetBackgroundColor(UIColor.pureBlack(0.75));
47 | backgroundPanel.addPlugin(backgroundPanelAnimColor);
48 | });
49 | addChildComponent("backgroundPanel", backgroundPanel);
50 |
51 | final Panel mainPanel = new Panel();
52 | mainPanel.setOnInitAction(() -> {
53 | mainPanel.setTopLeftPos(-540, -128);
54 | mainPanel.setBottomRightPos(0, 0);
55 | mainPanel.setTopLeftAnchor(mousePercent);
56 | mainPanel.setBottomRightAnchor(mousePercent);
57 | });
58 | backgroundPanel.addChildComponent("mainPanel", mainPanel);
59 |
60 | final UIColor[] colorButtons = new UIColor[]{
61 | UIColor.matRed(),
62 | UIColor.matPink(),
63 | UIColor.matPurple(),
64 | UIColor.matDeepPurple(),
65 | UIColor.matIndigo(),
66 | UIColor.matBlue(),
67 | UIColor.matLightBlue(),
68 | UIColor.matCyan(),
69 | UIColor.matTeal(),
70 | UIColor.matGreen(),
71 | UIColor.matLightGreen(),
72 | UIColor.matLime(),
73 | UIColor.matYellow(),
74 | UIColor.matAmber(),
75 | UIColor.matOrange(),
76 | UIColor.matDeepOrange(),
77 | UIColor.matBrown(),
78 | UIColor.matGrey(),
79 | UIColor.matBlueGrey()
80 | };
81 |
82 | int i = 0;
83 | for (UIColor col : colorButtons) {
84 | mainPanel.addChildComponent("colBtn" + String.valueOf(i), getColorButton(col, i));
85 | i++;
86 | }
87 |
88 | final TextButton cancelButton = new TextButton();
89 | cancelButton.setOnInitAction(() -> {
90 | cancelButton.setTopLeftPos(-152, -48);
91 | cancelButton.setBottomRightPos(-24, -24);
92 | cancelButton.setTopLeftAnchor(1, 1);
93 | cancelButton.setBottomRightAnchor(1, 1);
94 | cancelButton.setText(LangManager.getItem("cancel"));
95 | });
96 | cancelButton.setOnLMBAction(() -> {
97 | assert parentComponent instanceof FluidUIScreen;
98 | ((FluidUIScreen) parentComponent).setOverlayUiScreen(null); //Hide on cancel
99 | });
100 | mainPanel.addChildComponent("cancelButton", cancelButton);
101 |
102 | }
103 |
104 | private void confirmColor(UIColor col) {
105 | assert parentComponent instanceof FluidUIScreen;
106 | ((FluidUIScreen) parentComponent).setOverlayUiScreen(null); //Hide on confirm
107 |
108 | if (callback != null) {
109 | callback.execute(col);
110 | }
111 | }
112 |
113 | private Button getColorButton(UIColor col, int i) {
114 | Button btn = new Button();
115 | btn.setOnInitAction(() -> {
116 | btn.setTopLeftPos(24 + (26 * i), 24);
117 | btn.setBottomRightPos(48 + (26 * i), 48);
118 | btn.setTopLeftAnchor(0, 0);
119 | btn.setBottomRightAnchor(0, 0);
120 | btn.setBackgroundIdleColor(col);
121 | btn.setBackgroundActiveColor(col.alpha(0.5));
122 | });
123 | btn.setOnLMBAction(() -> confirmColor(col));
124 |
125 | return btn;
126 | }
127 |
128 | }
129 |
130 |
--------------------------------------------------------------------------------