diff --git a/redhorizon-cli/source/nz/net/ultraq/redhorizon/cli/mediaplayer/MediaPlayer.groovy b/redhorizon-cli/source/nz/net/ultraq/redhorizon/cli/mediaplayer/MediaPlayer.groovy index 5ae561aa..a4b20d15 100644 --- a/redhorizon-cli/source/nz/net/ultraq/redhorizon/cli/mediaplayer/MediaPlayer.groovy +++ b/redhorizon-cli/source/nz/net/ultraq/redhorizon/cli/mediaplayer/MediaPlayer.groovy @@ -1,12 +1,12 @@ -/* +/* * Copyright 2022, Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,6 +32,7 @@ import nz.net.ultraq.redhorizon.filetypes.AnimationFile import nz.net.ultraq.redhorizon.filetypes.ImageFile import nz.net.ultraq.redhorizon.filetypes.ImagesFile import nz.net.ultraq.redhorizon.filetypes.Palette +import nz.net.ultraq.redhorizon.filetypes.ResourceFile import nz.net.ultraq.redhorizon.filetypes.SoundFile import nz.net.ultraq.redhorizon.filetypes.VideoFile @@ -57,7 +58,7 @@ class MediaPlayer extends Application { private static final Logger logger = LoggerFactory.getLogger(MediaPlayer) - private final Object mediaFile + private final ResourceFile mediaFile private final Palette palette private MediaLoader mediaLoader @@ -69,7 +70,7 @@ class MediaPlayer extends Application { * @param graphicsConfig * @param paletteType */ - MediaPlayer(Object mediaFile, AudioConfiguration audioConfig, GraphicsConfiguration graphicsConfig, Palette palette) { + MediaPlayer(ResourceFile mediaFile, AudioConfiguration audioConfig, GraphicsConfiguration graphicsConfig, Palette palette) { super('Media Player', audioConfig, graphicsConfig) this.mediaFile = mediaFile diff --git a/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/media/MediaLoader.groovy b/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/media/MediaLoader.groovy index 24395751..2dcc3efa 100644 --- a/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/media/MediaLoader.groovy +++ b/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/media/MediaLoader.groovy @@ -1,12 +1,12 @@ -/* +/* * Copyright 2022, Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,16 +17,17 @@ package nz.net.ultraq.redhorizon.engine.media import nz.net.ultraq.redhorizon.engine.scenegraph.Scene +import nz.net.ultraq.redhorizon.filetypes.ResourceFile /** * An object that can be used to create media types from media files, and attach * them to existing game engines. - * + * * @param The type of file to load. * @param The type of media loaded from the file. * @author Emanuel Rabina */ -abstract class MediaLoader { +abstract class MediaLoader { protected final F file protected final Scene scene @@ -34,7 +35,7 @@ abstract class MediaLoader { /** * Constructor, create a new loader for the given media file. - * + * * @param file * @param scene */ diff --git a/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/resources/Resource.groovy b/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/resources/Resource.groovy new file mode 100644 index 00000000..8b6f8837 --- /dev/null +++ b/redhorizon-engine/source/nz/net/ultraq/redhorizon/engine/resources/Resource.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2024, Emanuel Rabina (http://www.ultraq.net.nz/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package nz.net.ultraq.redhorizon.engine.resources + +/** + * Base type for all resources, usually loaded from a corresponding resource + * file, eg: a texture can be built from an image file. + * + * @author Emanuel Rabina + */ +interface Resource { +} diff --git a/redhorizon-explorer/source/nz/net/ultraq/redhorizon/explorer/Explorer.groovy b/redhorizon-explorer/source/nz/net/ultraq/redhorizon/explorer/Explorer.groovy index ab3a4c10..916bc03f 100644 --- a/redhorizon-explorer/source/nz/net/ultraq/redhorizon/explorer/Explorer.groovy +++ b/redhorizon-explorer/source/nz/net/ultraq/redhorizon/explorer/Explorer.groovy @@ -27,8 +27,8 @@ import nz.net.ultraq.redhorizon.engine.input.KeyEvent import nz.net.ultraq.redhorizon.engine.media.AnimationLoader import nz.net.ultraq.redhorizon.engine.media.ImageLoader import nz.net.ultraq.redhorizon.engine.media.ImagesLoader -import nz.net.ultraq.redhorizon.engine.media.MediaLoader import nz.net.ultraq.redhorizon.engine.media.Playable +import nz.net.ultraq.redhorizon.engine.media.ResourceLoader import nz.net.ultraq.redhorizon.engine.media.SoundLoader import nz.net.ultraq.redhorizon.engine.media.VideoLoader import nz.net.ultraq.redhorizon.filetypes.AnimationFile @@ -64,7 +64,7 @@ class Explorer extends Application { private File currentDirectory private InputStream selectedFileInputStream private Object selectedFile - private MediaLoader selectedLoader + private ResourceLoader selectedLoader private Palette palette /** diff --git a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/AnimationFile.groovy b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/AnimationFile.groovy index f8e67fd7..a8e6937b 100644 --- a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/AnimationFile.groovy +++ b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/AnimationFile.groovy @@ -1,12 +1,12 @@ -/* +/* * Copyright 2007, Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,15 +20,15 @@ import java.nio.ByteBuffer /** * Interface for animation filetypes. - * + * * @author Emanuel Rabina */ -interface AnimationFile extends ImageBase { +interface AnimationFile extends ImageBase, ResourceFile { /** * Get the uncompressed data for each frame of the animation that can be used * for rendering. - * + * * @return Buffer for each frame. */ ByteBuffer[] getFrameData() @@ -36,14 +36,14 @@ interface AnimationFile extends ImageBase { /** * Returns the speed at which this animation should be run, in * frames-per-second. - * + * * @return */ float getFrameRate() /** * Return the number of frames that make up this animation. - * + * * @return */ int getNumFrames() diff --git a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImageFile.groovy b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImageFile.groovy index 230eca77..d2a29b23 100644 --- a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImageFile.groovy +++ b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImageFile.groovy @@ -1,12 +1,12 @@ -/* +/* * Copyright 2007 Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,14 +20,14 @@ import java.nio.ByteBuffer /** * Interface for image file formats. - * + * * @author Emanuel Rabina */ -interface ImageFile extends ImageBase { +interface ImageFile extends ImageBase, ResourceFile { /** * Return the image data of the file. - * + * * @return Buffer of the bytes in RGB(A) order for the image. */ ByteBuffer getImageData() diff --git a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImagesFile.groovy b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImagesFile.groovy index ac55f7b7..e7a885ba 100644 --- a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImagesFile.groovy +++ b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ImagesFile.groovy @@ -1,12 +1,12 @@ /* * Copyright 2007 Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,21 +22,21 @@ import java.nio.ByteBuffer * Interface for files which contain multiple images, but not to be played in * sequence like an animation. The images all share the same dimensions and * colour format. - * + * * @author Emanuel Rabina */ -interface ImagesFile extends ImageBase { +interface ImagesFile extends ImageBase, ResourceFile { /** * Returns the image data for all of the images in this file. - * + * * @return Image data for each image. */ ByteBuffer[] getImagesData() /** * Returns the number of images in this file. - * + * * @return Number of images. */ int getNumImages() diff --git a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ResourceFile.groovy b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ResourceFile.groovy new file mode 100644 index 00000000..889f4173 --- /dev/null +++ b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/ResourceFile.groovy @@ -0,0 +1,26 @@ +/* + * Copyright 2024, Emanuel Rabina (http://www.ultraq.net.nz/) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package nz.net.ultraq.redhorizon.filetypes + +/** + * Base type for all files that contain data that can be used for a resource, + * eg: an image file can be loaded to build a texture. + * + * @author Emanuel Rabina + */ +interface ResourceFile { +} diff --git a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/SoundFile.groovy b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/SoundFile.groovy index b188d3c3..b98924c9 100644 --- a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/SoundFile.groovy +++ b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/SoundFile.groovy @@ -1,12 +1,12 @@ /* * Copyright 2007, Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,10 +20,10 @@ import java.nio.ByteBuffer /** * Interface for filetypes for sound data (eg: AUD, WAV, etc...). - * + * * @author Emanuel Rabina */ -interface SoundFile { +interface SoundFile extends ResourceFile { /** * Returns the number of bits used for each sound sample. @@ -42,7 +42,7 @@ interface SoundFile { /** * Returns uncompressed sound data that can be used for playback. - * + * * @return The buffer of sound data. */ ByteBuffer getSoundData() @@ -50,7 +50,7 @@ interface SoundFile { /** * Return whether this file is best read using a streaming strategy, best for * larger sound files like music tracks. - * + * * @return */ default boolean isForStreaming() { diff --git a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/VideoFile.groovy b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/VideoFile.groovy index 8e1f53d1..e9a17fb2 100644 --- a/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/VideoFile.groovy +++ b/redhorizon-filetypes/source/nz/net/ultraq/redhorizon/filetypes/VideoFile.groovy @@ -1,12 +1,12 @@ -/* +/* * Copyright 2007 Emanuel Rabina (http://www.ultraq.net.nz/) - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,8 +18,8 @@ package nz.net.ultraq.redhorizon.filetypes /** * A video file format, containing both frames and an audio stream. - * + * * @author Emanuel Rabina */ -interface VideoFile extends AnimationFile, SoundFile, Streaming { +interface VideoFile extends AnimationFile, SoundFile, Streaming, ResourceFile { }