├── .gitignore
├── README.md
├── assets
├── shaders
│ └── pixelui
│ │ ├── blur.sprite.glsl
│ │ ├── hsl.primitive.glsl
│ │ ├── hsl.sprite.glsl
│ │ ├── lut.sprite.glsl
│ │ └── pixelation.sprite.glsl
└── sprites
│ └── pixelui
│ ├── cursors
│ └── arrow.png
│ ├── fonts
│ ├── font.fnt
│ ├── font.png
│ ├── font_small.fnt
│ └── font_small.png
│ ├── icons
│ ├── back.icon.png
│ ├── close.icon.png
│ ├── color_picker.icon.png
│ ├── extend.icon.png
│ ├── forward.icon.png
│ ├── information.icon.png
│ ├── key_case.icon.png
│ ├── key_delete.icon.png
│ └── question.icon.png
│ ├── misc
│ ├── color_picker_colors.png
│ ├── colors_overlay.png
│ ├── pixel.png
│ └── pixel_transparent.png
│ └── ui
│ ├── border.png
│ ├── button.png
│ ├── button_pressed.png
│ ├── checkbox.png
│ ├── checkbox_cell.png
│ ├── combobox.png
│ ├── combobox_cell.png
│ ├── combobox_list.png
│ ├── combobox_list_cell.png
│ ├── combobox_list_cell_selected.png
│ ├── combobox_open.png
│ ├── combobox_top.png
│ ├── context_menu.png
│ ├── context_menu_cell.png
│ ├── context_menu_cell_selected.png
│ ├── context_menu_top.png
│ ├── grid.png
│ ├── grid_cell.png
│ ├── grid_cell_selected.png
│ ├── grid_cell_selected_x2.png
│ ├── grid_cell_x2.png
│ ├── grid_dragged.png
│ ├── grid_dragged_x2.png
│ ├── grid_x2.png
│ ├── knob.png
│ ├── knob_background.png
│ ├── knob_endless.png
│ ├── list.png
│ ├── list_cell.png
│ ├── list_cell_selected.png
│ ├── list_drag.png
│ ├── mouseinput_lowercase.png
│ ├── mousetextinput_button.png
│ ├── mousetextinput_confirm.png
│ ├── mousetextinput_delete.png
│ ├── mousetextinput_lowercase.png
│ ├── mousetextinput_selected.png
│ ├── mousetextinput_uppercase.png
│ ├── notification_bar.png
│ ├── progressbar.png
│ ├── progressbar_bar.png
│ ├── radio.png
│ ├── radio_cell.png
│ ├── scrollbar_button_horizontal.png
│ ├── scrollbar_button_vertical.png
│ ├── scrollbar_horizontal.png
│ ├── scrollbar_vertical.png
│ ├── separator_horizontal.png
│ ├── separator_vertical.png
│ ├── tab.png
│ ├── tab__bigicon_selected.png
│ ├── tab_bigicon.png
│ ├── tab_border.png
│ ├── tab_selected.png
│ ├── textfield.png
│ ├── textfield_caret.png
│ ├── textfield_cell.png
│ ├── textfield_cell_validation.png
│ ├── tooltip.png
│ ├── tooltip_cell.png
│ ├── tooltip_line_horizontal.png
│ ├── tooltip_line_vertical.png
│ ├── tooltip_segment_border.png
│ ├── tooltip_top.png
│ └── window.png
├── core
├── pom.xml
└── src
│ └── main
│ └── java
│ └── net
│ └── mslivo
│ └── pixelui
│ ├── engine
│ ├── API.java
│ ├── APICamera.java
│ ├── APIComponent.java
│ ├── APIConfig.java
│ ├── APIContextMenu.java
│ ├── APIHotkey.java
│ ├── APIInput.java
│ ├── APIMouseTextInput.java
│ ├── APIMouseTool.java
│ ├── APINotification.java
│ ├── APITooltip.java
│ ├── APIWidgets.java
│ ├── APIWindow.java
│ ├── AppViewport.java
│ ├── Button.java
│ ├── Checkbox.java
│ ├── Combobox.java
│ ├── ComboboxItem.java
│ ├── Component.java
│ ├── ContextMenu.java
│ ├── ContextMenuItem.java
│ ├── FrameBufferViewport.java
│ ├── GenericNotification.java
│ ├── Grid.java
│ ├── HotKey.java
│ ├── Image.java
│ ├── ImageButton.java
│ ├── Knob.java
│ ├── List.java
│ ├── MouseTextInput.java
│ ├── MouseTool.java
│ ├── Notification.java
│ ├── Progressbar.java
│ ├── Scrollbar.java
│ ├── ScrollbarHorizontal.java
│ ├── ScrollbarVertical.java
│ ├── Shape.java
│ ├── Tab.java
│ ├── Tabbar.java
│ ├── Text.java
│ ├── TextButton.java
│ ├── Textfield.java
│ ├── Tooltip.java
│ ├── TooltipFramebufferViewportSegment.java
│ ├── TooltipImage.java
│ ├── TooltipImageSegment.java
│ ├── TooltipNotification.java
│ ├── TooltipSegment.java
│ ├── TooltipTextSegment.java
│ ├── UICommonUtils.java
│ ├── UIEngine.java
│ ├── UIEngineAdapter.java
│ ├── UIEngineConfig.java
│ ├── UIEngineState.java
│ ├── UIInputEvents.java
│ ├── UIInputProcessor.java
│ ├── Window.java
│ ├── WindowGenerator.java
│ ├── actions
│ │ ├── AppViewPortAction.java
│ │ ├── ButtonAction.java
│ │ ├── CheckboxAction.java
│ │ ├── ComboBoxAction.java
│ │ ├── ComboBoxItemAction.java
│ │ ├── ContextMenuAction.java
│ │ ├── ContextMenuItemAction.java
│ │ ├── FrameBufferViewportAction.java
│ │ ├── GridAction.java
│ │ ├── HasItemIcons.java
│ │ ├── HotKeyAction.java
│ │ ├── ImageAction.java
│ │ ├── KnobAction.java
│ │ ├── ListAction.java
│ │ ├── MouseTextInputAction.java
│ │ ├── NotificationAction.java
│ │ ├── ProgressBarAction.java
│ │ ├── ScrollBarAction.java
│ │ ├── ShapeAction.java
│ │ ├── TabAction.java
│ │ ├── TabBarAction.java
│ │ ├── TextAction.java
│ │ ├── TextFieldAction.java
│ │ ├── ToolTipAction.java
│ │ ├── UpdateAction.java
│ │ ├── UpdateActionSupport.java
│ │ ├── WindowAction.java
│ │ └── common
│ │ │ ├── CellColor.java
│ │ │ ├── CommonActions.java
│ │ │ ├── Displayable.java
│ │ │ ├── Icon.java
│ │ │ └── ItemCellColor.java
│ └── constants
│ │ ├── BUTTON_MODE.java
│ │ ├── CHECKBOX_STYLE.java
│ │ ├── DIRECTION.java
│ │ ├── INPUT_METHOD.java
│ │ ├── KeyCode.java
│ │ ├── MOUSE_CONTROL_MODE.java
│ │ ├── SEGMENT_ALIGNMENT.java
│ │ ├── SHAPE_ROTATION.java
│ │ ├── SHAPE_TYPE.java
│ │ ├── TILE_SIZE.java
│ │ ├── TOOLTIP_NOTIFICATION_STATE.java
│ │ ├── TOP_NOTIFICATION_STATE.java
│ │ └── VIEWPORT_MODE.java
│ ├── media
│ ├── CMedia.java
│ ├── CMediaAnimation.java
│ ├── CMediaArray.java
│ ├── CMediaFont.java
│ ├── CMediaFontArraySymbol.java
│ ├── CMediaFontOutline.java
│ ├── CMediaFontSingleSymbol.java
│ ├── CMediaFontSymbol.java
│ ├── CMediaImage.java
│ ├── CMediaMusic.java
│ ├── CMediaSound.java
│ ├── CMediaSoundEffect.java
│ ├── CMediaSprite.java
│ ├── LoadProgress.java
│ ├── MediaManager.java
│ ├── OUTLINE.java
│ └── UIEngineBaseMedia_8x8.java
│ ├── rendering
│ ├── BaseColorTweakRenderer.java
│ ├── BaseRenderer.java
│ ├── ExtendedAnimation.java
│ ├── IntegerIndexBufferObject.java
│ ├── NestedFrameBuffer.java
│ ├── PixelPerfectViewport.java
│ ├── PrimitiveRenderer.java
│ ├── ShaderParser.java
│ └── SpriteRenderer.java
│ └── utils
│ ├── PixelUILaunchConfig.java
│ ├── Tools.java
│ ├── appengine
│ ├── AppEngine.java
│ ├── AppEngineAdapter.java
│ ├── AppEngineIO.java
│ ├── AppEngineOutputQueue.java
│ └── AppEngineParameter.java
│ ├── misc
│ ├── CachedStringBuilder.java
│ ├── IntValueWatcher.java
│ ├── JSONIncludeParser.java
│ └── cli
│ │ ├── Hex2Float.java
│ │ └── Hex2FloatImage.java
│ ├── particles
│ ├── ParticleSystem.java
│ ├── ParticleUpdater.java
│ ├── PrimitiveParticleSystem.java
│ ├── SpriteParticleSystem.java
│ └── particles
│ │ ├── AnimationParticle.java
│ │ ├── ArrayParticle.java
│ │ ├── EmptyParticle.java
│ │ ├── ImageParticle.java
│ │ ├── Particle.java
│ │ ├── PrimitiveParticle.java
│ │ ├── SpriteParticle.java
│ │ ├── TextParticle.java
│ │ └── TextureBasedParticle.java
│ ├── settings
│ ├── SettingsEntry.java
│ ├── SettingsException.java
│ ├── SettingsManager.java
│ ├── SettingsPersistor.java
│ ├── ValueValidator.java
│ ├── persistor
│ │ └── PropertiesFilePersistor.java
│ └── validator
│ │ ├── BooleanValueValidator.java
│ │ ├── DecimalValueValidator.java
│ │ ├── EnumValueValidator.java
│ │ ├── NumberValueValidator.java
│ │ ├── StringListValueValidator.java
│ │ └── StringValueValidator.java
│ ├── sound
│ ├── MusicPlayer.java
│ └── SoundPlayer.java
│ └── transitions
│ ├── TRANSITION_RENDER_MODE.java
│ ├── TRANSITION_SPEED.java
│ ├── Transition.java
│ ├── TransitionManager.java
│ └── basic
│ ├── FadeTransition.java
│ ├── FallInTransition.java
│ ├── FallOutTransition.java
│ ├── ImmediateTransition.java
│ ├── PixelateTransition.java
│ ├── ZoomInTransition.java
│ └── ZoomOutTransition.java
├── desktop
├── assets_example
│ └── sprites
│ │ └── example
│ │ ├── background.png
│ │ ├── example_animation.png
│ │ ├── example_animation_2.png
│ │ ├── example_array.png
│ │ ├── example_bullet_blue.png
│ │ ├── example_bullet_green.png
│ │ ├── example_bullet_orange.png
│ │ ├── example_cursor.png
│ │ ├── example_icon_1.png
│ │ ├── example_icon_2.png
│ │ ├── example_icon_3.png
│ │ ├── example_icon_4.png
│ │ ├── example_icon_double.png
│ │ ├── example_icon_window.png
│ │ └── test.png
├── pom.xml
└── src
│ └── main
│ └── java
│ └── net
│ └── mslivo
│ ├── example
│ ├── ExampleLauncherMain.java
│ ├── ExampleMain.java
│ ├── ExampleMainConstants.java
│ └── ui
│ │ ├── ExampleUIEngineAdapter.java
│ │ ├── media
│ │ ├── ExampleBaseMedia.java
│ │ └── ParticleData.java
│ │ └── windows
│ │ └── ExampleWindowGeneratorP.java
│ └── performancetest
│ └── ThreadTest.java
├── logo.png
├── pom.xml
├── screenshot_1.png
└── screenshot_2.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Files #
2 | *.class
3 | *.log
4 | *.jar
5 | *.war
6 | *.nar
7 | *.ear
8 | *.zip
9 | *.tar.gz
10 | *.rar
11 | hs_err_pid*
12 | replay_pid*
13 |
14 | # Directories
15 | /.idea/**
16 | /dev/**
17 | /desktop/target/**
18 | /desktop/.lwjgl/**
19 | /core/target/**
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PixelUI Engine
2 | 
3 |
4 | Java UI-System on top of LibGDX which provides a tiny 8x8-tile based Window and Component system
5 | suited for low-resolution game and graphical applications.
6 | This is a work in progress and subject to change - no maven release exists.
7 |
8 | This library was used in the game [Sandtrix](https://www.sandtrix.net).
9 |
10 | ## Screenshots
11 | 
12 | 
13 |
14 | ## Features
15 | - Windows
16 | - Components
17 | - Button
18 | - Checkbox / Radiobox
19 | - Combobox
20 | - Image
21 | - Text
22 | - List
23 | - Grid
24 | - Knob
25 | - Canvas
26 | - Progressbar
27 | - Scrollbar
28 | - Shapes
29 | - Tabbars & Tabs
30 | - Textfield
31 | - AppViewPort
32 | - ToolTips
33 | - Context Menus
34 | - Notifications
35 | - Modals
36 | - Hotkeys
37 | - Drag & Drop
38 | - Keyboard, Gamepad & Mouse Input handling
39 | - Mouse emulation (Keyboard, Gamepad)
40 | - Gamepad & Touchscreen text inputs
41 | - Viewport handling / Pixel-Art upscaling
42 | - Asset-Management
43 | - High performance, low library size (~300kb)
44 | - Utility classes
45 | - Improved Sprite renderer
46 | - Primitive renderer (fast pixel rendering)
47 | - Particle system
48 | - Transition effects
49 | - Music & Sound players
50 | - Settings manager
51 |
52 |
53 |
54 | ## Overview
55 | ### desktop/ ... /example
56 |
57 | Basic example producing the UI in the screenshot above showcasing a typical setup for the engine.
58 |
59 | ### core/ ... /engine.media_manager
60 |
61 | This asset manager uses assets in the form of an internal CMedia descriptor format.
62 | These assets can then be loaded at once and used/drawn via the SpriteRenderer.
63 |
64 | The assets for the UI are contained in UIBaseMedia and need to be loaded alongside your own assets for the UI to work.
65 |
66 | ### core/ ... /engine.ui_engine
67 |
68 | The core of the Engine. A class implementing the UIAdapter interfaces needs to be implemented and passed to a new UIEngine object.
69 |
70 | The UIEngine then passes a API Object into the Adapter on init() from which all windows, components can be created.
71 |
72 | ### Tools
73 |
74 | These are not needed for the UI to work.
75 | This package contains useful classes that integrate seamlessly with the Engine and use the internal formats and classes.
76 |
77 | #### core.engine.tools/ ... AppEngine
78 |
79 | Provides a basic framework for an engine which works in update cycles, provides input/output handling.
80 | Uses the same Adapter approach as the UIEngine.
81 |
82 | #### core.engine.tools/ ... JsonInlcudeParser
83 |
84 | A json parser which supports include files via JSON comments.
85 |
86 | #### core.engine.tools/ ... ParticleSystem
87 |
88 | High performance particle systems using the MediaManager CMedia graphics formats and primitves.
89 |
90 | #### core.engine.tools/ ... SettingsManager
91 |
92 | A settings/options manager. Has failsafe functionality to ensure that all values are always valid.
93 | A Implementation for reading/writing to java-.properties files is provided via the FileSettingsPersistor, custom storage methods can be implemented.
94 |
95 | #### core.engine.tools/ ... SoundPlayer
96 |
97 | A Soundplayer that uses the MediaManager and CMedia sound format.
98 | This player supports playing sound in a virtual 2D space with automatic volume/pan adjustment based on distance and direction.
99 |
100 | #### core.engine.tools/ ... MusicPlayer
101 |
102 | A Musicplayer that uses MediaManager and CMedia music format.
103 | This player works like you would expect it from a regular music player application, which means it supports playlists/shuffle/pause/resume/... etc.
104 |
105 | #### core.engine.tools/ ... TransitionManager
106 |
107 | A tool to create Transition effects when switching between two UIEngine instances
108 |
109 | #### core.engine.tools/ ... Tools
110 |
111 | Static helper & math functions.
112 |
--------------------------------------------------------------------------------
/assets/shaders/pixelui/blur.sprite.glsl:
--------------------------------------------------------------------------------
1 | // Usable Vertex Shader Variables: vec4 a_position | vec4 v_color | vec4 v_tweak | vec2 v_texCoord
2 | // Usable Fragment Shader Variables: vec4 v_color | vec4 v_tweak | vec2 v_texCoord | sampler2D u_texture | vec2 u_textureSize
3 |
4 | // BEGIN VERTEX
5 |
6 |
7 | // END VERTEX
8 |
9 |
10 | // BEGIN FRAGMENT
11 |
12 | vec4 blur(vec2 texCoords, sampler2D texture, vec2 textureSize) {
13 | vec2 texelSize = 1.0 / textureSize;
14 | vec4 color = texture2D(texture, texCoords) * 4.0; // Center pixel
15 | color += texture2D(texture, texCoords + vec2(texelSize.x, 0.0));
16 | color += texture2D(texture, texCoords - vec2(texelSize.x, 0.0));
17 | color += texture2D(texture, texCoords + vec2(0.0, texelSize.y));
18 | color += texture2D(texture, texCoords - vec2(0.0, texelSize.y));
19 | color += texture2D(texture, texCoords + vec2(texelSize.x, texelSize.y));
20 | color += texture2D(texture, texCoords - vec2(texelSize.x, texelSize.y));
21 | color += texture2D(texture, texCoords + vec2(texelSize.x, -texelSize.y));
22 | color += texture2D(texture, texCoords - vec2(texelSize.x, -texelSize.y));
23 | return color / 12.0; // Normalize
24 | }
25 |
26 | void main(){
27 |
28 | vec4 color = texture2D(u_texture, v_texCoord);
29 | vec4 blurred = blur(v_texCoord, u_texture, u_textureSize);
30 |
31 | gl_FragColor = mix(color, blurred, v_tweak.x);
32 | }
33 |
34 | // END FRAGMENT
--------------------------------------------------------------------------------
/assets/shaders/pixelui/hsl.primitive.glsl:
--------------------------------------------------------------------------------
1 | // Usable Vertex Shader Variables: vec4 a_position | vec4 v_color | vec4 v_tweak | vec4 v_vertexColor
2 | // Usable Fragment Shader Variables: vec4 v_color | vec4 v_tweak | vec4 v_vertexColor
3 |
4 | // BEGIN VERTEX
5 |
6 | vec4 colorTintAdd(vec4 color, vec4 modColor){
7 | color.rgb = clamp(color.rgb+(modColor.rgb-0.5),0.0,1.0);
8 | color.a *= modColor.a;
9 | return color;
10 | }
11 |
12 |
13 | vec4 hsl2rgb(vec4 c)
14 | {
15 | const highp float eps = 1.0e-10;
16 | const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
17 | vec3 p = abs(fract(c.x + K.xyz) * 6.0 - K.www);
18 | float v = (c.z + c.y * min(c.z, 1.0 - c.z));
19 | return vec4(v * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), 2.0 * (1.0 - c.z / (v + eps))), c.w);
20 | }
21 |
22 | vec4 rgb2hsl(vec4 c)
23 | {
24 | const highp float eps = 1.0e-10;
25 | const vec4 J = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
26 | vec4 p = mix(vec4(c.bg, J.wz), vec4(c.gb, J.xy), step(c.b, c.g));
27 | vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
28 | float d = q.x - min(q.w, q.y);
29 | float l = q.x * (1.0 - 0.5 * d / (q.x + eps));
30 | return vec4(abs(q.z + (q.w - q.y) / (6.0 * d + eps)), (q.x - l) / (min(l, 1.0 - l) + eps), l, c.a);
31 | }
32 |
33 | void main(){
34 |
35 | v_vertexColor = colorTintAdd(v_vertexColor, v_color);
36 |
37 | vec4 hsl = rgb2hsl(v_vertexColor);
38 | hsl.x = fract(hsl.x + (v_tweak.x-0.5));
39 | hsl.y = clamp(hsl.y + ((v_tweak.y-0.5)*2.0),0.0,1.0);
40 | hsl.z = clamp(hsl.z + ((v_tweak.z-0.5)*2.0),0.0,1.0);
41 | v_vertexColor = hsl2rgb(hsl);
42 |
43 | }
44 |
45 |
46 | // END VERTEX
47 |
48 | // BEGIN FRAGMENT
49 |
50 | void main(){
51 | gl_FragColor = v_vertexColor;
52 | }
53 |
54 | // END FRAGMENT
--------------------------------------------------------------------------------
/assets/shaders/pixelui/hsl.sprite.glsl:
--------------------------------------------------------------------------------
1 | // Usable Vertex Shader Variables: vec4 a_position | vec4 v_color | vec4 v_tweak | vec2 v_texCoord
2 | // Usable Fragment Shader Variables: vec4 v_color | vec4 v_tweak | vec2 v_texCoord | sampler2D u_texture | vec2 u_textureSize
3 |
4 | // BEGIN VERTEX
5 |
6 |
7 | // END VERTEX
8 |
9 | // BEGIN FRAGMENT
10 |
11 | vec4 colorTintAdd(vec4 color, vec4 modColor){
12 | color.rgb = clamp(color.rgb+(modColor.rgb-0.5),0.0,1.0);
13 | color.a *= modColor.a;
14 | return color;
15 | }
16 |
17 | vec4 hsl2rgb(vec4 c)
18 | {
19 | const highp float eps = 1.0e-10;
20 | const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
21 | vec3 p = abs(fract(c.x + K.xyz) * 6.0 - K.www);
22 | float v = (c.z + c.y * min(c.z, 1.0 - c.z));
23 | return vec4(v * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), 2.0 * (1.0 - c.z / (v + eps))), c.w);
24 | }
25 |
26 | vec4 rgb2hsl(vec4 c)
27 | {
28 | const highp float eps = 1.0e-10;
29 | const vec4 J = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
30 | vec4 p = mix(vec4(c.bg, J.wz), vec4(c.gb, J.xy), step(c.b, c.g));
31 | vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
32 | float d = q.x - min(q.w, q.y);
33 | float l = q.x * (1.0 - 0.5 * d / (q.x + eps));
34 | return vec4(abs(q.z + (q.w - q.y) / (6.0 * d + eps)), (q.x - l) / (min(l, 1.0 - l) + eps), l, c.a);
35 | }
36 |
37 | void main(){
38 |
39 | vec4 color = colorTintAdd(texture2D(u_texture, v_texCoord),v_color);
40 |
41 | vec4 hsl = rgb2hsl(color);
42 | hsl.x = fract(hsl.x + (v_tweak.x-0.5));
43 | hsl.y = clamp(hsl.y + ((v_tweak.y-0.5)*2.0),0.0,1.0);
44 | hsl.z = clamp(hsl.z + ((v_tweak.z-0.5)*2.0),0.0,1.0);
45 | gl_FragColor = hsl2rgb(hsl);
46 |
47 | }
48 | // END FRAGMENT
49 |
--------------------------------------------------------------------------------
/assets/shaders/pixelui/lut.sprite.glsl:
--------------------------------------------------------------------------------
1 | // Usable Vertex Shader Variables: vec4 a_position | vec4 v_color | vec4 v_tweak | vec2 v_texCoord
2 | // Usable Fragment Shader Variables: vec4 v_color | vec4 v_tweak | vec2 v_texCoord | sampler2D u_texture | vec2 u_textureSize
3 |
4 | // BEGIN VERTEX
5 |
6 | // END VERTEX
7 |
8 |
9 | // BEGIN FRAGMENT
10 |
11 | uniform sampler2D u_lut;
12 | uniform vec2 u_lutSize;
13 |
14 | vec3 lut(vec3 color, sampler2D lutTexture, vec2 lutTextureSize) {
15 | float lutSize = lutTextureSize.y;
16 | float sliceSize = 1.0 / lutSize;
17 | float slicePixelSize = sliceSize / lutSize;
18 | float width = lutSize - 1.0;
19 | float sliceInnerSize = slicePixelSize * width;
20 |
21 | float zSlice0 = floor(color.z * width);
22 | float zSlice1 = min(zSlice0 + 1.0, width);
23 | float xOffset = slicePixelSize * 0.5 + color.x * sliceInnerSize;
24 | float yRange = (color.y * width + 0.5) / lutSize;
25 | float s0 = xOffset + (zSlice0 * sliceSize);
26 | float s1 = xOffset + (zSlice1 * sliceSize);
27 |
28 | vec3 slice0Color = texture2D(lutTexture, vec2(s0, yRange)).rgb;
29 | vec3 slice1Color = texture2D(lutTexture, vec2(s1, yRange)).rgb;
30 |
31 | float zOffset = mod(color.z * width, 1.0);
32 |
33 | return mix(slice0Color, slice1Color, zOffset);
34 | }
35 |
36 |
37 |
38 | void main(){
39 |
40 | vec4 color = texture2D(u_texture, v_texCoord);
41 | vec4 lutColor = vec4(lut(color.rgb,u_lut, u_lutSize),color.a);
42 |
43 | gl_FragColor = mix(color,lutColor,v_tweak.x);
44 |
45 | }
46 |
47 | // END FRAGMENT
--------------------------------------------------------------------------------
/assets/shaders/pixelui/pixelation.sprite.glsl:
--------------------------------------------------------------------------------
1 | // Usable Vertex Shader Variables: vec4 a_position | vec4 v_color | vec4 v_tweak | vec4 v_vertexColor
2 | // Usable Fragment Shader Variables: vec4 v_color | vec4 v_tweak | vec4 v_vertexColor
3 |
4 | // BEGIN VERTEX
5 |
6 | // END VERTEX
7 |
8 | // BEGIN FRAGMENT
9 |
10 | void main(){
11 |
12 | highp vec2 texCoords = v_texCoord;
13 | float pixelSize = 2.0 + floor(v_tweak.x * 14.0);
14 | texCoords = texCoords * u_textureSize;
15 | texCoords = mix(texCoords, floor((texCoords / pixelSize) + 0.5) * pixelSize, step(0.001, v_tweak.x));
16 | texCoords = texCoords / u_textureSize;
17 | gl_FragColor = texture2D( u_texture, texCoords);
18 |
19 | }
20 |
21 | // END FRAGMENT
--------------------------------------------------------------------------------
/assets/sprites/pixelui/cursors/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/cursors/arrow.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/fonts/font.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/fonts/font.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/fonts/font_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/fonts/font_small.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/back.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/back.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/close.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/close.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/color_picker.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/color_picker.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/extend.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/extend.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/forward.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/forward.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/information.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/information.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/key_case.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/key_case.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/key_delete.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/key_delete.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/icons/question.icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/icons/question.icon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/misc/color_picker_colors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/misc/color_picker_colors.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/misc/colors_overlay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/misc/colors_overlay.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/misc/pixel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/misc/pixel.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/misc/pixel_transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/misc/pixel_transparent.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/border.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/button.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/button_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/button_pressed.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/checkbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/checkbox.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/checkbox_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/checkbox_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox_list.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox_list_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox_list_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox_list_cell_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox_list_cell_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox_open.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/combobox_top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/combobox_top.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/context_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/context_menu.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/context_menu_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/context_menu_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/context_menu_cell_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/context_menu_cell_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/context_menu_top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/context_menu_top.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_cell_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_cell_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_cell_selected_x2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_cell_selected_x2.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_cell_x2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_cell_x2.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_dragged.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_dragged.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_dragged_x2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_dragged_x2.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/grid_x2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/grid_x2.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/knob.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/knob.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/knob_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/knob_background.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/knob_endless.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/knob_endless.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/list.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/list_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/list_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/list_cell_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/list_cell_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/list_drag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/list_drag.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mouseinput_lowercase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mouseinput_lowercase.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mousetextinput_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mousetextinput_button.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mousetextinput_confirm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mousetextinput_confirm.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mousetextinput_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mousetextinput_delete.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mousetextinput_lowercase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mousetextinput_lowercase.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mousetextinput_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mousetextinput_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/mousetextinput_uppercase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/mousetextinput_uppercase.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/notification_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/notification_bar.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/progressbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/progressbar.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/progressbar_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/progressbar_bar.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/radio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/radio.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/radio_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/radio_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/scrollbar_button_horizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/scrollbar_button_horizontal.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/scrollbar_button_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/scrollbar_button_vertical.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/scrollbar_horizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/scrollbar_horizontal.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/scrollbar_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/scrollbar_vertical.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/separator_horizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/separator_horizontal.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/separator_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/separator_vertical.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tab.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tab__bigicon_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tab__bigicon_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tab_bigicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tab_bigicon.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tab_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tab_border.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tab_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tab_selected.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/textfield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/textfield.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/textfield_caret.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/textfield_caret.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/textfield_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/textfield_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/textfield_cell_validation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/textfield_cell_validation.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tooltip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tooltip.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tooltip_cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tooltip_cell.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tooltip_line_horizontal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tooltip_line_horizontal.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tooltip_line_vertical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tooltip_line_vertical.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tooltip_segment_border.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tooltip_segment_border.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/tooltip_top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/tooltip_top.png
--------------------------------------------------------------------------------
/assets/sprites/pixelui/ui/window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/assets/sprites/pixelui/ui/window.png
--------------------------------------------------------------------------------
/core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | net.mslivo
7 | pixeluiengine
8 | 1.0
9 |
10 |
11 | pixeluiengine-core
12 | jar
13 |
14 |
15 |
16 |
17 |
18 |
19 | com.badlogicgames.gdx
20 | gdx
21 |
22 |
23 | com.badlogicgames.gdx
24 | gdx-backend-lwjgl3
25 |
26 |
27 | com.badlogicgames.gdx
28 | gdx-platform
29 | natives-desktop
30 |
31 |
32 |
33 |
34 |
35 | com.badlogicgames.gdx-controllers
36 | gdx-controllers-core
37 |
38 |
39 | com.badlogicgames.gdx-controllers
40 | gdx-controllers-desktop
41 |
42 |
43 |
44 |
45 |
46 | com.github.Dgzt
47 | gdx-lwjgl3-angle-vulkan
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | ../assets
57 |
58 |
59 | src/main/java
60 |
61 | **/*.java
62 | **/*.gwt.xml
63 |
64 |
65 |
66 |
67 |
68 | org.apache.maven.plugins
69 | maven-compiler-plugin
70 |
71 |
72 | org.apache.maven.plugins
73 | maven-jar-plugin
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/APICamera.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.math.Matrix4;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.media.MediaManager;
6 |
7 | public final class APICamera {
8 | private final API api;
9 | private final UIEngineState uiEngineState;
10 | private final UICommonUtils uiCommonUtils;
11 | private final MediaManager mediaManager;
12 | private final UIEngineConfig uiEngineConfig;
13 |
14 | public final APIAppViewports appViewport;
15 |
16 | APICamera(API api, UIEngineState uiEngineState, UICommonUtils uiCommonUtils, MediaManager mediaManager) {
17 | this.api = api;
18 | this.uiEngineState = uiEngineState;
19 | this.uiCommonUtils = uiCommonUtils;
20 | this.mediaManager = mediaManager;
21 | this.uiEngineConfig = uiEngineState.config;
22 |
23 | this.appViewport = new APIAppViewports();
24 | }
25 |
26 | public boolean pointVisible(float x, float y) {
27 | if (uiEngineState.camera_app.frustum.pointInFrustum(x, y, 0f)) return true;
28 | return false;
29 | }
30 |
31 | public boolean rectVisible(float x, float y, float width, float height) {
32 | if (uiEngineState.camera_app.frustum.boundsInFrustum(x, y, 0f, width, height, 0f)) return true;
33 | return false;
34 | }
35 |
36 | public boolean sphereVisible(float x, float y, float radius) {
37 | if (uiEngineState.camera_app.frustum.sphereInFrustum(x, y, 0f, radius)) return true;
38 | return false;
39 | }
40 |
41 | public void setPosition(float x, float y) {
42 | uiCommonUtils.camera_setPosition(uiEngineState.camera_app, x, y);
43 | }
44 |
45 | public void move(float x, float y) {
46 | uiCommonUtils.camera_setPosition(uiEngineState.camera_app,
47 | (uiEngineState.camera_app.position.x + x),
48 | (uiEngineState.camera_app.position.y + y)
49 | );
50 | }
51 |
52 | public void setX(float x) {
53 | uiCommonUtils.camera_setPosition(uiEngineState.camera_app,
54 | x,
55 | uiEngineState.camera_app.position.y
56 | );
57 | }
58 |
59 | public void moveX(float x) {
60 | uiCommonUtils.camera_setPosition(uiEngineState.camera_app,
61 | (uiEngineState.camera_app.position.x + x),
62 | uiEngineState.camera_app.position.y
63 | );
64 | }
65 |
66 | public void setY(float y) {
67 | uiCommonUtils.camera_setPosition(uiEngineState.camera_app,
68 | uiEngineState.camera_app.position.x,
69 | y
70 | );
71 | }
72 |
73 | public void moveY(float y) {
74 | uiCommonUtils.camera_setPosition(uiEngineState.camera_app,
75 | uiEngineState.camera_app.position.x,
76 | (uiEngineState.camera_app.position.y + y)
77 | );
78 | }
79 |
80 | public void setZoom(float zoom) {
81 | uiCommonUtils.camera_setZoom(uiEngineState.camera_app, zoom);
82 | }
83 |
84 | public float x() {
85 | return uiEngineState.camera_app.position.x;
86 | }
87 |
88 | public float y() {
89 | return uiEngineState.camera_app.position.y;
90 | }
91 |
92 | public float z() {
93 | return uiEngineState.camera_app.position.z;
94 | }
95 |
96 | public float zoom() {
97 | return uiEngineState.camera_app.zoom;
98 | }
99 |
100 | public Matrix4 projection() {
101 | return uiEngineState.camera_app.combined;
102 | }
103 |
104 | public Matrix4 projectionUI() {
105 | return uiEngineState.camera_ui.combined;
106 | }
107 |
108 | public float viewPortStretchFactorWidth() {
109 | return uiEngineState.viewport_screen.getWorldWidth() / (float) uiEngineState.viewport_screen.getScreenWidth();
110 | }
111 |
112 | public float viewPortStretchFactorHeight() {
113 | return uiEngineState.viewport_screen.getWorldHeight() / (float) uiEngineState.viewport_screen.getScreenHeight();
114 | }
115 |
116 | public final class APIAppViewports {
117 |
118 | APIAppViewports() {
119 | }
120 |
121 | public int activeSize() {
122 | return uiEngineState.appViewPorts.size;
123 | }
124 |
125 | public AppViewport get(int index) {
126 | return uiEngineState.appViewPorts.get(index);
127 | }
128 |
129 | private Array getAll() {
130 | return new Array<>(uiEngineState.appViewPorts);
131 | }
132 |
133 | public boolean pointVisible(AppViewport appViewPort, float x, float y) {
134 | return appViewPort.camera.frustum.pointInFrustum(x, y, 0f);
135 | }
136 |
137 | public boolean pointVisibleAny(float x, float y) {
138 | for (int i = 0; i < uiEngineState.appViewPorts.size; i++) {
139 | if (pointVisible(uiEngineState.appViewPorts.get(i), x, y)) return true;
140 | }
141 | return false;
142 | }
143 |
144 | public boolean rectVisible(AppViewport appViewPort, float x, float y, float width, float height) {
145 | return appViewPort.camera.frustum.boundsInFrustum(x, y, 0f, width, height, 0f);
146 | }
147 |
148 | public boolean rectVisibleAny(float x, float y, float width, float height) {
149 | for (int i = 0; i < uiEngineState.appViewPorts.size; i++) {
150 | if (rectVisible(uiEngineState.appViewPorts.get(i), x, y, width, height)) return true;
151 | }
152 | return false;
153 | }
154 |
155 | public boolean sphereVisible(AppViewport appViewPort, float x, float y, float radius) {
156 | return appViewPort.camera.frustum.sphereInFrustum(x, y, 0f, radius);
157 | }
158 |
159 | public boolean sphereVisibleAny(float x, float y, float width, float radius) {
160 | for (int i = 0; i < uiEngineState.appViewPorts.size; i++) {
161 | if (sphereVisible(uiEngineState.appViewPorts.get(i), x, y, radius)) return true;
162 | }
163 | return false;
164 | }
165 |
166 | }
167 |
168 | }
169 |
170 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/APIHotkey.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.MediaManager;
4 | import net.mslivo.pixelui.utils.Tools;
5 | import net.mslivo.pixelui.engine.actions.HotKeyAction;
6 |
7 | import java.util.Arrays;
8 |
9 | public final class APIHotkey {
10 | private final API api;
11 | private final UIEngineState uiEngineState;
12 | private final UICommonUtils uiCommonUtils;
13 | private final MediaManager mediaManager;
14 | private final UIEngineConfig uiEngineConfig;
15 |
16 | APIHotkey(API api, UIEngineState uiEngineState, UICommonUtils uiCommonUtils, MediaManager mediaManager) {
17 | this.api = api;
18 | this.uiEngineState = uiEngineState;
19 | this.uiCommonUtils = uiCommonUtils;
20 | this.mediaManager = mediaManager;
21 | this.uiEngineConfig = uiEngineState.config;
22 |
23 | }
24 |
25 | public final HotKeyAction DEFAULT_HOTKEY_ACTION = new HotKeyAction() {
26 | };
27 |
28 | public HotKey create(int keyCode, HotKeyAction hotKeyAction) {
29 | return create(new int[]{keyCode}, hotKeyAction);
30 | }
31 |
32 | public HotKey create(int[] keyCodes, HotKeyAction hotKeyAction) {
33 | HotKey hotKey = new HotKey();
34 | hotKey.pressed = false;
35 | hotKey.keyCodes = keyCodes != null ? Arrays.copyOf(keyCodes, keyCodes.length) : new int[]{};
36 | hotKey.hotKeyAction = hotKeyAction != null ? hotKeyAction : DEFAULT_HOTKEY_ACTION;
37 | hotKey.name = "";
38 | hotKey.data = null;
39 | return hotKey;
40 | }
41 |
42 | public void setKeyCodes(HotKey hotKey, int[] keyCodes) {
43 | if (hotKey == null) return;
44 | hotKey.keyCodes = Arrays.copyOf(keyCodes, keyCodes.length);
45 | }
46 |
47 | public void setHotKeyAction(HotKey hotKey, HotKeyAction hotKeyAction) {
48 | if (hotKey == null) return;
49 | hotKey.hotKeyAction = hotKeyAction != null ? hotKeyAction : DEFAULT_HOTKEY_ACTION;
50 | }
51 |
52 | public void setName(HotKey hotKey, String name) {
53 | if (hotKey == null) return;
54 | hotKey.name = Tools.Text.validString(name);
55 | }
56 |
57 | public void setData(HotKey hotKey, Object data) {
58 | if (hotKey == null) return;
59 | hotKey.data = data;
60 | }
61 |
62 | public String keysAsText(HotKey hotKey) {
63 | String[] names = new String[hotKey.keyCodes.length];
64 | for (int i = 0; i < hotKey.keyCodes.length; i++) {
65 | names[i] = com.badlogic.gdx.Input.Keys.toString(hotKey.keyCodes[i]);
66 | }
67 | return String.join("+", names);
68 | }
69 | }
70 |
71 |
72 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/APIMouseTool.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.MediaManager;
4 | import net.mslivo.pixelui.media.CMediaSprite;
5 | import net.mslivo.pixelui.utils.Tools;
6 |
7 | public final class APIMouseTool {
8 | private final API api;
9 | private final UIEngineState uiEngineState;
10 | private final UICommonUtils uiCommonUtils;
11 | private final MediaManager mediaManager;
12 | private final UIEngineConfig uiEngineConfig;
13 |
14 |
15 | APIMouseTool(API api, UIEngineState uiEngineState, UICommonUtils uiCommonUtils, MediaManager mediaManager) {
16 | this.api = api;
17 | this.uiEngineState = uiEngineState;
18 | this.uiCommonUtils = uiCommonUtils;
19 | this.mediaManager = mediaManager;
20 | this.uiEngineConfig = uiEngineState.config;
21 | }
22 |
23 | public MouseTool create(String name, Object data, CMediaSprite cursor) {
24 | return create(name, data, cursor, cursor);
25 | }
26 |
27 | public MouseTool create(String name, Object data, CMediaSprite cursor, CMediaSprite cursorDown) {
28 | MouseTool mouseTool = new MouseTool();
29 | mouseTool.name = name;
30 | mouseTool.data = data;
31 | mouseTool.cursor = cursor;
32 | mouseTool.cursorDown = cursorDown;
33 | mouseTool.cursorArrayIndex = 0;
34 | return mouseTool;
35 | }
36 |
37 | public void setName(MouseTool mouseTool, String name) {
38 | if (mouseTool == null) return;
39 | mouseTool.name = Tools.Text.validString(name);
40 | }
41 |
42 | public void setData(MouseTool mouseTool, Object data) {
43 | if (mouseTool == null) return;
44 | mouseTool.data = data;
45 | }
46 |
47 | public void setCursor(MouseTool mouseTool, CMediaSprite cursor) {
48 | if (mouseTool == null) return;
49 | mouseTool.cursor = cursor;
50 | }
51 |
52 | public void setCursorDown(MouseTool mouseTool, CMediaSprite cursorDown) {
53 | if (mouseTool == null) return;
54 | mouseTool.cursorDown = cursorDown;
55 | }
56 |
57 | public void setCursorArrayIndex(MouseTool mouseTool, int cursorArrayIndex) {
58 | if (mouseTool == null) return;
59 | mouseTool.cursorArrayIndex = Math.max(0, cursorArrayIndex);
60 | }
61 |
62 | }
63 |
64 |
65 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/AppViewport.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.OrthographicCamera;
4 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
5 | import net.mslivo.pixelui.rendering.NestedFrameBuffer;
6 | import net.mslivo.pixelui.engine.actions.AppViewPortAction;
7 |
8 | public class AppViewport extends Component {
9 | public OrthographicCamera camera;
10 | public NestedFrameBuffer frameBuffer;
11 | public TextureRegion textureRegion;
12 | public AppViewPortAction appViewPortAction;
13 | public long updateTimer;
14 | public int updateTime;
15 |
16 | AppViewport() {
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Button.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.constants.BUTTON_MODE;
4 | import net.mslivo.pixelui.engine.actions.ButtonAction;
5 |
6 | public abstract sealed class Button extends Component permits ImageButton, TextButton {
7 | public ButtonAction buttonAction;
8 | public boolean pressed;
9 | public BUTTON_MODE mode;
10 | public boolean toggleDisabled;
11 | public int contentOffset_x;
12 | public int contentOffset_y;
13 |
14 | Button() {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Checkbox.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.constants.CHECKBOX_STYLE;
5 | import net.mslivo.pixelui.engine.actions.CheckboxAction;
6 |
7 | public class Checkbox extends Component {
8 | public CHECKBOX_STYLE checkBoxStyle;
9 | public String text;
10 | public boolean checked;
11 | public Color fontColor;
12 | public CheckboxAction checkBoxAction;
13 |
14 | Checkbox() {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Combobox.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.utils.Array;
4 | import net.mslivo.pixelui.engine.actions.ComboBoxAction;
5 |
6 | public class Combobox extends Component {
7 | public Array items;
8 | public ComboBoxAction comboBoxAction;
9 | public ComboboxItem selectedItem;
10 |
11 | Combobox() {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/ComboboxItem.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.actions.ComboBoxItemAction;
5 |
6 | public class ComboboxItem {
7 | public String text;
8 | public Color fontColor;
9 | public ComboBoxItemAction comboBoxItemAction;
10 | public Combobox addedToComboBox;
11 | public String name;
12 | public Object data;
13 |
14 | ComboboxItem() {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Component.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.actions.UpdateActionSupport;
5 |
6 | public abstract class Component extends UpdateActionSupport {
7 | public int x, y, width, height;
8 | public Color color;
9 | public Color color2;
10 | public boolean disabled;
11 | public boolean visible;
12 | public Tab addedToTab;
13 | public String name;
14 | public Object data;
15 | public Window addedToWindow; // set by engine
16 | public boolean addedToScreen;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/ContextMenu.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.engine.actions.ContextMenuAction;
6 |
7 | public class ContextMenu {
8 | public int x, y;
9 | public Color color;
10 | public Array items;
11 | public ContextMenuAction contextMenuAction;
12 |
13 | ContextMenu() {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/ContextMenuItem.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.actions.ContextMenuItemAction;
5 |
6 | public class ContextMenuItem {
7 | public String text;
8 | public Color fontColor;
9 | public ContextMenuItemAction contextMenuItemAction;
10 | public ContextMenu addedToContextMenu;
11 | public String name;
12 | public Object data;
13 |
14 | ContextMenuItem() {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/FrameBufferViewport.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.rendering.NestedFrameBuffer;
4 | import net.mslivo.pixelui.engine.actions.FrameBufferViewportAction;
5 |
6 | public class FrameBufferViewport extends Component {
7 | public NestedFrameBuffer frameBuffer;
8 | public FrameBufferViewportAction frameBufferViewportAction;
9 | public boolean flipX, flipY,stretchToSize;
10 |
11 | FrameBufferViewport() {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/GenericNotification.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | public abstract sealed class GenericNotification permits Notification, TooltipNotification {
4 | public long timer;
5 | public int displayTime;
6 | public String name;
7 | public Object data;
8 | public boolean addedToScreen;
9 |
10 | GenericNotification() {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Grid.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.actions.GridAction;
4 |
5 | import java.util.HashSet;
6 |
7 | public class Grid extends Component {
8 | public T[][] items;
9 | public GridAction gridAction;
10 | public T selectedItem;
11 | public boolean multiSelect;
12 | public HashSet selectedItems;
13 | public boolean dragEnabled;
14 | public boolean dragOutEnabled;
15 | public boolean dragInEnabled;
16 | public boolean bigMode;
17 |
18 | Grid() {
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/HotKey.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.actions.HotKeyAction;
4 |
5 | public class HotKey {
6 | public int[] keyCodes;
7 | public boolean pressed;
8 | public HotKeyAction hotKeyAction;
9 | public String name;
10 | public Object data;
11 |
12 | HotKey() {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Image.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.CMediaSprite;
4 | import net.mslivo.pixelui.engine.actions.ImageAction;
5 |
6 | public class Image extends Component {
7 | public CMediaSprite image;
8 | public int arrayIndex;
9 | public ImageAction imageAction;
10 | public boolean flipX, flipY,stretchToSize;
11 |
12 | Image() {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/ImageButton.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.CMediaSprite;
4 |
5 | public final class ImageButton extends Button {
6 | public CMediaSprite image;
7 | public int arrayIndex;
8 |
9 | ImageButton() {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Knob.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.actions.KnobAction;
4 |
5 | public class Knob extends Component {
6 | public float turned;
7 | public KnobAction knobAction;
8 | public boolean endless;
9 |
10 | Knob() {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/List.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.engine.actions.ListAction;
6 |
7 | import java.util.HashSet;
8 |
9 | public class List extends Component {
10 | public Array items;
11 | public float scrolled;
12 | public ListAction listAction;
13 | public Color fontColor;
14 | public T selectedItem; // singleselect
15 | public boolean multiSelect;
16 | public HashSet selectedItems; // multiselect
17 | public boolean dragEnabled;
18 | public boolean dragOutEnabled;
19 | public boolean dragInEnabled;
20 |
21 | List() {
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/MouseTextInput.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.IntArray;
5 | import net.mslivo.pixelui.engine.actions.MouseTextInputAction;
6 |
7 | public class MouseTextInput {
8 | public int x,y;
9 | public char[] charactersLC;
10 | public char[] charactersUC;
11 | public Color color;
12 | public Color color2;
13 | public Color fontColor;
14 | public int selectedIndex;
15 | public boolean upperCase;
16 | public MouseTextInputAction mouseTextInputAction;
17 | public IntArray enterCharacterQueue;
18 |
19 | MouseTextInput() {
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/MouseTool.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.CMediaSprite;
4 |
5 | public class MouseTool {
6 | public String name;
7 | public Object data;
8 | public CMediaSprite cursor;
9 | public int cursorArrayIndex;
10 | public CMediaSprite cursorDown;
11 |
12 | MouseTool() {
13 | }
14 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Notification.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.constants.TOP_NOTIFICATION_STATE;
5 | import net.mslivo.pixelui.engine.actions.NotificationAction;
6 |
7 | public final class Notification extends GenericNotification {
8 | public String text;
9 | public TOP_NOTIFICATION_STATE state;
10 | public boolean uiInteractionEnabled;
11 | public Color color;
12 | public Color fontColor;
13 | public int scroll;
14 | public int scrollMax;
15 | public NotificationAction notificationAction;
16 |
17 | Notification() {
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Progressbar.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.actions.ProgressBarAction;
5 |
6 | public class Progressbar extends Component {
7 | public float progress;
8 | public boolean progressText;
9 | public boolean progressText2Decimal;
10 | public Color fontColor;
11 | public ProgressBarAction progressBarAction;
12 |
13 | Progressbar() {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Scrollbar.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.actions.ScrollBarAction;
4 |
5 | public abstract sealed class Scrollbar extends Component permits ScrollbarHorizontal, ScrollbarVertical {
6 | public float scrolled;
7 | public boolean buttonPressed;
8 | public ScrollBarAction scrollBarAction;
9 |
10 | Scrollbar() {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/ScrollbarHorizontal.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | public final class ScrollbarHorizontal extends Scrollbar {
4 | ScrollbarHorizontal() {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/ScrollbarVertical.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | public final class ScrollbarVertical extends Scrollbar {
4 | ScrollbarVertical() {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Shape.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.constants.SHAPE_ROTATION;
4 | import net.mslivo.pixelui.engine.constants.SHAPE_TYPE;
5 | import net.mslivo.pixelui.engine.actions.ShapeAction;
6 |
7 | public class Shape extends Component {
8 | public SHAPE_TYPE shapeType;
9 | public SHAPE_ROTATION shapeRotation;
10 | public ShapeAction shapeAction;
11 |
12 | Shape() {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Tab.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.engine.actions.TabAction;
6 |
7 | public class Tab {
8 | public String title;
9 | public int width;
10 | public TabAction tabAction;
11 | public Tabbar addedToTabBar;
12 | public Color fontColor;
13 | public Array components;
14 | public String name;
15 | public Object data;
16 | public boolean disabled;
17 |
18 | Tab() {
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Tabbar.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.utils.Array;
4 | import net.mslivo.pixelui.engine.actions.TabBarAction;
5 |
6 | public class Tabbar extends Component {
7 | public Array tabs;
8 | public int selectedTab;
9 | public TabBarAction tabBarAction;
10 | public boolean border;
11 | public int borderHeight;
12 | public int tabOffset;
13 | public boolean bigIconMode;
14 |
15 | Tabbar() {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Text.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.actions.TextAction;
5 |
6 | public class Text extends Component {
7 | public String text;
8 | public Color fontColor;
9 | public TextAction textAction;
10 |
11 | Text() {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TextButton.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 |
5 | public final class TextButton extends Button {
6 | public String text;
7 | public Color fontColor;
8 |
9 | TextButton() {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Textfield.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.IntSet;
5 | import net.mslivo.pixelui.engine.actions.TextFieldAction;
6 |
7 | public class Textfield extends Component {
8 | public String content;
9 | public Color fontColor;
10 | public Color markerColor;
11 | public TextFieldAction textFieldAction;
12 | public int contentMaxLength;
13 | public int offset;
14 | public IntSet allowedCharacters;
15 | public int caretPosition;
16 | public int markedContentBegin;
17 | public int markedContentEnd;
18 | public boolean contentValid;
19 |
20 | Textfield() {
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Tooltip.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.engine.constants.DIRECTION;
6 | import net.mslivo.pixelui.engine.actions.UpdateActionSupport;
7 | import net.mslivo.pixelui.engine.actions.ToolTipAction;
8 |
9 | public class Tooltip extends UpdateActionSupport {
10 | public ToolTipAction toolTipAction;
11 | public Array segments;
12 | public int minWidth;
13 | public Color color_border;
14 | public Color color_line;
15 | public int lineLength;
16 | public DIRECTION direction;
17 | public String name;
18 | public Object data;
19 |
20 | Tooltip() {
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TooltipFramebufferViewportSegment.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.rendering.NestedFrameBuffer;
4 |
5 | public final class TooltipFramebufferViewportSegment extends TooltipSegment {
6 |
7 | public NestedFrameBuffer frameBuffer;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TooltipImage.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.CMediaSprite;
4 |
5 | public class TooltipImage {
6 | public CMediaSprite image;
7 | public int x;
8 | public int y;
9 | public float color_r, color_g, color_b, color_a;
10 | public Tooltip addedToToolTip;
11 |
12 | TooltipImage() {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TooltipImageSegment.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.media.CMediaSprite;
4 |
5 | public final class TooltipImageSegment extends TooltipSegment {
6 |
7 | public CMediaSprite image;
8 | public int arrayIndex;
9 | public boolean flipX, flipY;
10 |
11 | TooltipImageSegment() {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TooltipNotification.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import net.mslivo.pixelui.engine.constants.TOOLTIP_NOTIFICATION_STATE;
4 |
5 | public non-sealed class TooltipNotification extends GenericNotification {
6 | public int x,y;
7 | public Tooltip tooltip;
8 | public TOOLTIP_NOTIFICATION_STATE state;
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TooltipSegment.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.engine.constants.SEGMENT_ALIGNMENT;
5 |
6 | public abstract sealed class TooltipSegment permits TooltipFramebufferViewportSegment, TooltipImageSegment, TooltipTextSegment {
7 | public Tooltip addedToTooltip;
8 | public Color cellColor;
9 | public Color contentColor;
10 | public SEGMENT_ALIGNMENT alignment;
11 | public int width;
12 | public int height;
13 | public boolean border;
14 | public boolean merge;
15 | public boolean clear;
16 |
17 | TooltipSegment() {
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/TooltipTextSegment.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | public final class TooltipTextSegment extends TooltipSegment {
4 | public String text;
5 |
6 | TooltipTextSegment() {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/UIEngineAdapter.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.OrthographicCamera;
4 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
5 | import com.badlogic.gdx.utils.Disposable;
6 | import net.mslivo.pixelui.rendering.SpriteRenderer;
7 | import net.mslivo.pixelui.media.MediaManager;
8 |
9 | public interface UIEngineAdapter extends Disposable {
10 | void init(API api, MediaManager mediaManager);
11 | void update();
12 | void render(OrthographicCamera camera, AppViewport appViewPort);
13 |
14 | default void renderComposite(OrthographicCamera camera, SpriteRenderer spriteRenderer, TextureRegion texture_game, TextureRegion texture_uiComponent, TextureRegion texture_uiModal,
15 | int resolutionWidth, int resolutionHeight, boolean modalActive) {
16 | spriteRenderer.setProjectionMatrix(camera.combined);
17 | spriteRenderer.setBlendFunctionComposite();
18 | spriteRenderer.begin();
19 |
20 | if(modalActive){
21 | spriteRenderer.setTweak(0.5f,0f,0.45f,0.0f);
22 | spriteRenderer.draw(texture_game, 0, 0, resolutionWidth, resolutionHeight);
23 | spriteRenderer.draw(texture_uiComponent, 0, 0, resolutionWidth, resolutionHeight);
24 | spriteRenderer.setAllReset();
25 | }else{
26 | spriteRenderer.draw(texture_game, 0, 0, resolutionWidth, resolutionHeight);
27 | spriteRenderer.draw(texture_uiComponent, 0, 0, resolutionWidth, resolutionHeight);
28 | }
29 | spriteRenderer.draw(texture_uiModal, 0, 0, resolutionWidth, resolutionHeight);
30 |
31 | spriteRenderer.end();
32 | spriteRenderer.setAllReset();
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/UIInputEvents.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.utils.IntArray;
4 | import net.mslivo.pixelui.engine.constants.INPUT_METHOD;
5 |
6 | public final class UIInputEvents {
7 |
8 | public INPUT_METHOD lastUsedInputMethod;
9 |
10 | /* --- Hardware Mouse --- */
11 | public boolean mouseDown;
12 | public boolean mouseDoubleClick;
13 | public boolean mouseUp;
14 | public boolean mouseDragged;
15 | public boolean mouseMoved;
16 | public boolean mouseScrolled;
17 | public final boolean[] mouseButtonsDown;
18 | public final IntArray mouseUpButtons;
19 | public final IntArray mouseDownButtons;
20 | public float mouseScrolledAmount;
21 | public int mouseUpButtonIndex,mouseDownButtonIndex;
22 | /* --- Keyboard --- */
23 | public boolean keyDown;
24 | public boolean keyUp;
25 | public boolean keyTyped;
26 | public final boolean[] keysDown;
27 | public final IntArray keyTypedCharacters;
28 | public final IntArray keyUpKeyCodes;
29 | public final IntArray keyDownKeyCodes;
30 | public int keyTypedCharacterIndex, keyUpKeyCodeIndex, keyDownKeyCodeIndex;
31 | /* --- GamePad --- */
32 | public boolean gamePadConnected;
33 | public boolean gamePadDisconnected;
34 | public boolean gamePadLeftXMoved;
35 | public boolean gamePadLeftYMoved;
36 | public float gamePadLeftX;
37 | public float gamePadLeftY;
38 | public boolean gamePadRightXMoved;
39 | public boolean gamePadRightYMoved;
40 | public float gamePadRightX;
41 | public float gamePadRightY;
42 | public boolean gamePadLeftTriggerMoved;
43 | public float gamePadLeftTrigger;
44 | public boolean gamePadRightTriggerMoved;
45 | public float gamePadRightTrigger;
46 | public boolean gamePadButtonDown;
47 | public boolean gamePadButtonUp;
48 | public IntArray gamePadButtonDownKeyCodes;
49 | public IntArray gamePadButtonUpKeyCodes;
50 | public final boolean[] gamePadButtonsDown;
51 | public int gamePadButtonDownIndex,gamePadButtonUpIndex;
52 |
53 | UIInputEvents() {
54 | lastUsedInputMethod = INPUT_METHOD.NONE;
55 | // Mouse
56 | mouseDownButtons = new IntArray();
57 | mouseButtonsDown = new boolean[5];
58 | // Keyboard
59 | keyUpKeyCodes = new IntArray();
60 | keyDownKeyCodes = new IntArray();
61 | keyTypedCharacters = new IntArray();
62 | keysDown = new boolean[256];
63 | mouseUpButtons = new IntArray();
64 | // GamePad
65 | gamePadButtonDownKeyCodes = new IntArray();
66 | gamePadButtonUpKeyCodes = new IntArray();
67 | gamePadButtonsDown = new boolean[18];
68 | this.reset();
69 | }
70 |
71 | public void reset() {
72 | // Keys
73 | keyDown = false;
74 | keyUp = false;
75 | keyTyped = false;
76 | keyUpKeyCodes.clear();
77 | keyDownKeyCodes.clear();
78 | keyTypedCharacters.clear();
79 | mouseUpButtons.clear();
80 | mouseDownButtons.clear();
81 | // Mouse
82 | mouseDown = false;
83 | mouseUp = false;
84 | mouseDragged = false;
85 | mouseScrolled = false;
86 | mouseMoved = false;
87 | mouseDoubleClick = false;
88 | // GamePad
89 | gamePadConnected = false;
90 | gamePadDisconnected = false;
91 | gamePadLeftXMoved = false;
92 | gamePadLeftYMoved = false;
93 | gamePadRightXMoved = false;
94 | gamePadRightYMoved = false;
95 | gamePadLeftTriggerMoved = false;
96 | gamePadRightTriggerMoved = false;
97 | gamePadButtonDown = false;
98 | gamePadButtonUp = false;
99 | gamePadButtonDownKeyCodes.clear();
100 | gamePadButtonUpKeyCodes.clear();
101 | // API Return Indexes
102 | mouseUpButtonIndex = 0;
103 | mouseDownButtonIndex = 0;
104 | keyTypedCharacterIndex = 0;
105 | keyUpKeyCodeIndex = 0;
106 | keyDownKeyCodeIndex = 0;
107 | gamePadButtonDownIndex = 0;
108 | gamePadButtonUpIndex = 0;
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/Window.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.engine.actions.UpdateActionSupport;
6 | import net.mslivo.pixelui.engine.actions.WindowAction;
7 |
8 | /**
9 | * Created by Admin on 09.03.2019.
10 | */
11 | public class Window extends UpdateActionSupport {
12 | public int x, y, width, height;
13 | public String title;
14 | public Color fontColor;
15 | public Array components;
16 | public String name;
17 | public Object data;
18 | public Color color;
19 | public boolean alwaysOnTop;
20 | public boolean folded;
21 | public boolean moveAble;
22 | public boolean hasTitleBar;
23 | public boolean visible;
24 | public boolean enforceScreenBounds;
25 | public WindowAction windowAction;
26 | public boolean addedToScreen;
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/WindowGenerator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine;
2 |
3 | public class WindowGenerator {
4 |
5 | public interface P0 {
6 | Window createWindow(API api);
7 | }
8 |
9 | public interface P1 {
10 | Window createWindow(API api, P1 p1);
11 | }
12 |
13 | public interface P2 {
14 | Window createWindow(API api, P1 p1, P2 p2);
15 | }
16 |
17 | public interface P3 {
18 | Window createWindow(API api, P1 p1, P2 p2, P3 p3);
19 | }
20 |
21 | public interface P4 {
22 | Window createWindow(API api, P1 p1, P2 p2, P3 p3, P4 p4);
23 | }
24 |
25 | public interface P5 {
26 | Window createWindow(API api, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/AppViewPortAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface AppViewPortAction extends CommonActions {
6 |
7 | default void onPress(int x, int y) {
8 | }
9 |
10 | default void onRelease() {
11 | }
12 |
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ButtonAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.Icon;
5 |
6 | public interface ButtonAction extends CommonActions, Icon {
7 |
8 | default void onPress() {
9 | }
10 |
11 | default void onRelease() {
12 | }
13 |
14 | default void onToggle(boolean value) {
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/CheckboxAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface CheckboxAction extends CommonActions {
6 |
7 | default void onCheck(boolean checked) {
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ComboBoxAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.Displayable;
5 | import net.mslivo.pixelui.engine.ComboboxItem;
6 |
7 | public interface ComboBoxAction extends CommonActions, Displayable {
8 |
9 | default void onItemSelected(ComboboxItem selectedItem) {
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ComboBoxItemAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CellColor;
4 | import net.mslivo.pixelui.engine.actions.common.Icon;
5 |
6 | public interface ComboBoxItemAction extends Icon, CellColor {
7 | default void onSelect() {
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ContextMenuAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.Displayable;
5 | import net.mslivo.pixelui.engine.ContextMenuItem;
6 |
7 | public interface ContextMenuAction extends CommonActions, Displayable {
8 |
9 | default void onItemSelected(ContextMenuItem selectedItem) {
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ContextMenuItemAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CellColor;
4 | import net.mslivo.pixelui.engine.actions.common.Icon;
5 |
6 | public interface ContextMenuItemAction extends Icon, CellColor {
7 |
8 | default void onSelect() {
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/FrameBufferViewportAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface FrameBufferViewportAction extends CommonActions {
6 |
7 | default void onPress(int x, int y) {
8 | }
9 |
10 | default void onRelease() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/GridAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.ItemCellColor;
5 | import net.mslivo.pixelui.engine.Grid;
6 | import net.mslivo.pixelui.engine.List;
7 | import net.mslivo.pixelui.engine.Tooltip;
8 |
9 | public interface GridAction extends CommonActions, HasItemIcons, ItemCellColor {
10 |
11 | default Tooltip toolTip(T gridItem) {
12 | return null;
13 | }
14 |
15 | default boolean onItemSelected(T gridItem) {
16 | return true;
17 | }
18 |
19 | default void onDragFromGrid(Grid fromGrid, int from_x, int from_y, int to_x, int to_y) {
20 | }
21 |
22 | default void onDragFromList(List fromList, int fromIndex, int to_x, int to_y) {
23 | }
24 |
25 | default boolean canDragFromGrid(Grid fromGrid) {
26 | return false;
27 | }
28 |
29 | default boolean canDragFromList(List fromList) {
30 | return false;
31 | }
32 |
33 | default void onDragIntoApp(T gridItem, int from_x, int from_y, int screenX, int screenY) {
34 | }
35 |
36 | default boolean canDragIntoApp() {
37 | return false;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/HasItemIcons.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.media.CMediaSprite;
5 |
6 | public interface HasItemIcons {
7 |
8 | default CMediaSprite icon(T item){
9 | return null;
10 | };
11 |
12 | default int iconIndex(T item) {
13 | return 0;
14 | }
15 |
16 | default Color iconColor(T item){
17 | return Color.GRAY;
18 | }
19 |
20 | default boolean iconFlipX(){return false;}
21 |
22 | default boolean iconFlipY(){return false;}
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/HotKeyAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | public interface HotKeyAction {
4 |
5 | default void onPress(){}
6 |
7 | default void onRelease(){}
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ImageAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface ImageAction extends CommonActions {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/KnobAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface KnobAction extends CommonActions {
6 |
7 | default void onTurned(float turned, float amount){
8 | }
9 |
10 | default void onPress(){
11 | }
12 |
13 | default void onRelease(){
14 | }
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ListAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.ItemCellColor;
4 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
5 | import net.mslivo.pixelui.engine.Grid;
6 | import net.mslivo.pixelui.engine.List;
7 | import net.mslivo.pixelui.engine.Tooltip;
8 |
9 | public interface ListAction extends CommonActions, HasItemIcons, ItemCellColor {
10 |
11 | default Tooltip toolTip(T listItem) {
12 | return null;
13 | }
14 |
15 | default String text(T listItem) {
16 | return listItem.toString();
17 | }
18 |
19 | default boolean onItemSelected(T listItem) {
20 | return true;
21 | }
22 |
23 | default void onScrolled(float scrolled) {
24 | }
25 |
26 | /* Drag */
27 |
28 | default void onDragFromList(List fromList, int fromIndex, int toIndex) {
29 | }
30 |
31 | default void onDragFromGrid(Grid fromGrid, int from_x, int from_y, int toIndex) {
32 | }
33 |
34 | default boolean canDragFromList(List list) {
35 | return false;
36 | }
37 |
38 | default boolean canDragFromGrid(Grid fromGrid) {
39 | return false;
40 | }
41 |
42 | default void onDragIntoApp(T listItem, int mouseX, int mouseY) {
43 | }
44 |
45 | default boolean canDragIntoApp() {
46 | return false;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/MouseTextInputAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.Displayable;
4 |
5 | public interface MouseTextInputAction extends Displayable {
6 |
7 | /*Return = close yes/no */
8 |
9 | default boolean onConfirm(){
10 | return true;
11 | }
12 | default void onEnterCharacter(char c){return;}
13 | default void onChangeCase(boolean upperCase){return;}
14 | default void onDelete(){return;}
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/NotificationAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.Displayable;
5 |
6 | public interface NotificationAction extends CommonActions, Displayable {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ProgressBarAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface ProgressBarAction extends CommonActions {
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ScrollBarAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface ScrollBarAction extends CommonActions {
6 |
7 | default void onScrolled(float scrolled) {
8 | }
9 |
10 | default void onPress(float scrolled) {
11 | }
12 |
13 | default void onRelease(float scrolled) {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ShapeAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface ShapeAction extends CommonActions {
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/TabAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.Icon;
4 |
5 | public interface TabAction extends Icon {
6 |
7 | default void onSelect(){
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/TabBarAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.Tab;
5 |
6 | public interface TabBarAction extends CommonActions {
7 |
8 | default void onChangeTab(int index, Tab tab){}
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/TextAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.Icon;
5 |
6 | public interface TextAction extends CommonActions, Icon {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/TextFieldAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 |
5 | public interface TextFieldAction extends CommonActions {
6 |
7 | default boolean isContentValid(String newContent) {
8 | return true;
9 | }
10 |
11 | default void onContentChange(String newContent, boolean valid) {
12 | }
13 |
14 | default void onTyped(char character) {
15 | }
16 |
17 | default void onEnter(String content, boolean valid) {
18 | }
19 |
20 | default void onFocus() {
21 | }
22 |
23 | default void onUnFocus() {
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/ToolTipAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.Displayable;
4 |
5 | public interface ToolTipAction extends Displayable {
6 |
7 | default void onUpdate() {
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/UpdateAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | /**
4 | * Created by Admin on 16.03.2019.
5 | */
6 | public abstract class UpdateAction {
7 |
8 | public final int interval;
9 |
10 | public long timer;
11 |
12 | public UpdateAction() {
13 | this(0, false);
14 | }
15 |
16 | public UpdateAction(int interval) {
17 | this(interval, false);
18 | }
19 |
20 | public UpdateAction(int interval, boolean updateOnInit) {
21 | this.interval = interval;
22 | this.timer = updateOnInit ? interval: 0 ;
23 | }
24 |
25 | public void onUpdate() {
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/UpdateActionSupport.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import com.badlogic.gdx.utils.Array;
4 |
5 | public abstract class UpdateActionSupport {
6 | public Array updateActions;
7 | }
8 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/WindowAction.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions;
2 |
3 | import net.mslivo.pixelui.engine.actions.common.CommonActions;
4 | import net.mslivo.pixelui.engine.actions.common.Displayable;
5 | import net.mslivo.pixelui.engine.actions.common.Icon;
6 |
7 | public interface WindowAction extends CommonActions, Icon, Displayable {
8 |
9 | default void onMove(int x, int y) {
10 | }
11 |
12 | default void onFold() {
13 | }
14 |
15 | default void onUnfold() {
16 | }
17 |
18 | default void onMessageReceived(int type, Object... parameters) {
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/common/CellColor.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions.common;
2 |
3 |
4 | import com.badlogic.gdx.graphics.Color;
5 |
6 | public interface CellColor {
7 |
8 | default Color cellColor(){
9 | return Color.WHITE;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/common/CommonActions.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions.common;
2 |
3 | import net.mslivo.pixelui.engine.Tooltip;
4 |
5 | public interface CommonActions {
6 |
7 | default void onMousePress(int button) {
8 | }
9 |
10 | default void onMouseRelease(int button) {
11 | }
12 |
13 | default void onMouseDoubleClick(int button) {
14 | }
15 |
16 | default void onMouseScroll(float scrolled) {
17 | }
18 |
19 | default Tooltip onShowTooltip(){
20 | return null;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/common/Displayable.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions.common;
2 |
3 | public interface Displayable {
4 | default void onDisplay() {
5 | }
6 |
7 | default void onRemove() {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/common/Icon.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions.common;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import net.mslivo.pixelui.media.CMediaSprite;
5 |
6 | public interface Icon {
7 |
8 | default CMediaSprite icon(){
9 | return null;
10 | };
11 |
12 | default int iconIndex() {
13 | return 0;
14 | }
15 |
16 | default Color iconColor(){
17 | return Color.GRAY;
18 | }
19 |
20 | default boolean iconFlipX(){return false;}
21 |
22 | default boolean iconFlipY(){return false;}
23 | }
24 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/actions/common/ItemCellColor.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.actions.common;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 |
5 | public interface ItemCellColor {
6 |
7 | default Color cellColor(T item){
8 | return Color.WHITE;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/BUTTON_MODE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum BUTTON_MODE {
4 | DEFAULT("Default"),
5 | TOGGLE("Toggle");
6 |
7 | private final String text;
8 |
9 | BUTTON_MODE(String text) {
10 | this.text = text;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/CHECKBOX_STYLE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum CHECKBOX_STYLE {
4 | CHECKBOX("Checkbox"), RADIO("Radio");
5 |
6 | public final String text;
7 |
8 | CHECKBOX_STYLE(String text) {
9 | this.text = text;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/DIRECTION.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum DIRECTION {
4 | UP("Up",0,1), DOWN("Down",0,-1), LEFT("Left",-1,0), RIGHT("Right",1,0);
5 |
6 | public final String text;
7 | public final int dx;
8 | public final int dy;
9 |
10 | DIRECTION(String text, int dx, int dy) {
11 | this.text = text;
12 | this.dx = dx;
13 | this.dy = dy;
14 | }
15 |
16 | public DIRECTION turnLeft() {
17 | return switch (this) {
18 | case UP -> LEFT;
19 | case DOWN -> RIGHT;
20 | case LEFT -> DOWN;
21 | case RIGHT -> UP;
22 | };
23 | }
24 |
25 | public DIRECTION turnRight() {
26 | return switch (this) {
27 | case UP -> RIGHT;
28 | case DOWN -> LEFT;
29 | case LEFT -> UP;
30 | case RIGHT -> DOWN;
31 | };
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/INPUT_METHOD.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum INPUT_METHOD {
4 | HARDWARE_MOUSE("Mouse"),
5 | KEYBOARD("Keyboard"),
6 | GAMEPAD("Gamepad"),
7 | NONE("None");
8 |
9 | public final String text;
10 |
11 | INPUT_METHOD(String text) {
12 | this.text = text;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/MOUSE_CONTROL_MODE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum MOUSE_CONTROL_MODE {
4 | HARDWARE_MOUSE("Mouse", false),
5 | KEYBOARD("Keyboard", true),
6 | GAMEPAD("Gamepad", true),
7 | DISABLED("Disabled", false);
8 |
9 | public final String text;
10 | public final boolean emulated;
11 | MOUSE_CONTROL_MODE(String text, boolean emulated){
12 | this.text = text;
13 | this.emulated = emulated;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/SEGMENT_ALIGNMENT.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum SEGMENT_ALIGNMENT {
4 | LEFT("Left"),
5 | CENTER("Center"),
6 | RIGHT("Right");
7 |
8 | public final String text;
9 |
10 | SEGMENT_ALIGNMENT(String text) {
11 | this.text = text;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/SHAPE_ROTATION.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum SHAPE_ROTATION {
4 | DEGREE_0("0°"),
5 | DEGREE_90("90°"),
6 | DEGREE_180("180°"),
7 | DEGREE_270("270°");
8 |
9 | public final String text;
10 |
11 | SHAPE_ROTATION(String text) {
12 | this.text = text;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/SHAPE_TYPE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum SHAPE_TYPE {
4 | RECT("Rect"),
5 | DIAMOND("Diamond"),
6 | OVAL("Oval"),
7 | RIGHT_TRIANGLE("Right Triangle"),
8 | ISOSCELES_TRIANGLE("Isosceles Triangle");
9 |
10 | public final String text;
11 |
12 | SHAPE_TYPE(String text) {
13 | this.text = text;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/TILE_SIZE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum TILE_SIZE {
4 | MODE_8x8(8);
5 |
6 | public final int TS;
7 | public final int TS_HALF;
8 | public final int TS2;
9 | public final int TS3;
10 | public final int TS4;
11 | public final float TSF;
12 | public final float TLF_HALF;
13 | public final float TSF2;
14 | public final float TSF3;
15 | public final float TSF4;
16 |
17 | public int TL(int size){
18 | return (size* TS);
19 | }
20 |
21 | public float TLF(float size){
22 | return (size* TS);
23 | }
24 |
25 | TILE_SIZE(int tileSize) {
26 | this.TS = tileSize;
27 | this.TS_HALF = tileSize / 2;
28 | this.TS2 = tileSize * 2;
29 | this.TS3 = tileSize * 3;
30 | this.TS4 = tileSize * 4;
31 | this.TSF = (float) tileSize;
32 | this.TLF_HALF = TSF / 2f;
33 | this.TSF2 = TSF * 2f;
34 | this.TSF3 = TSF * 3f;
35 | this.TSF4 = TSF * 4f;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/TOOLTIP_NOTIFICATION_STATE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum TOOLTIP_NOTIFICATION_STATE {
4 | INIT("Init"),
5 | DISPLAY("Display"),
6 | FADE("Fade"),
7 | FINISHED("Finished");
8 |
9 | public final String text;
10 |
11 | TOOLTIP_NOTIFICATION_STATE(String text) {
12 | this.text = text;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/TOP_NOTIFICATION_STATE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum TOP_NOTIFICATION_STATE {
4 | INIT_SCROLL("Init Scroll"),
5 | INIT_DISPLAY("Init Display"),
6 | SCROLL("Scroll"),
7 | DISPLAY("Display"),
8 | FOLD("Fold"),
9 | FINISHED("Finished");
10 |
11 | public final String text;
12 |
13 | TOP_NOTIFICATION_STATE(String text) {
14 | this.text = text;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/engine/constants/VIEWPORT_MODE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.engine.constants;
2 |
3 | public enum VIEWPORT_MODE {
4 | PIXEL_PERFECT("Pixel Perfect", false),
5 | FIT("Fit", true),
6 | STRETCH("Stretch", true);
7 |
8 | public final String text;
9 | public final boolean upscale;
10 |
11 | VIEWPORT_MODE(String text, boolean upscale) {
12 | this.text = text;
13 | this.upscale= upscale;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMedia.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 | import java.util.Objects;
5 |
6 | public abstract sealed class CMedia implements Serializable permits CMediaFont, CMediaSound, CMediaSprite {
7 | public String file;
8 |
9 | public CMedia(){
10 | super();
11 | this.file = "";
12 | }
13 |
14 | CMedia(String file) {
15 | this.file = file;
16 | }
17 |
18 |
19 | protected void copyFields(CMedia copyFrom){
20 | this.file = copyFrom.file;
21 | }
22 |
23 | public CMedia copy(){
24 | CMedia copy= switch (this){
25 | case CMediaFont cMediaFont -> cMediaFont.copy();
26 | case CMediaSound cMediaSound -> cMediaSound.copy();
27 | case CMediaSprite cMediaSprite -> cMediaSprite.copy();
28 | };
29 | return copy;
30 | }
31 |
32 | @Override
33 | public boolean equals(Object o) {
34 | if (o == null || getClass() != o.getClass()) return false;
35 |
36 | CMedia cMedia = (CMedia) o;
37 | return Objects.equals(file, cMedia.file);
38 | }
39 |
40 | @Override
41 | public int hashCode() {
42 | return Objects.hashCode(file);
43 | }
44 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaAnimation.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import net.mslivo.pixelui.rendering.ExtendedAnimation;
4 |
5 | import java.io.Serializable;
6 |
7 | public final class CMediaAnimation extends CMediaSprite implements Serializable {
8 |
9 | public int frameWidth;
10 | public int frameHeight;
11 | public int frameOffset;
12 | public int frameLength;
13 | public float animationSpeed;
14 | public ExtendedAnimation.PlayMode playMode;
15 |
16 | public CMediaAnimation() {
17 | super();
18 | this.frameWidth = 0;
19 | this.frameHeight = 0;
20 | this.frameOffset = 0;
21 | this.frameLength = Integer.MAX_VALUE;
22 | this.animationSpeed = 0f;
23 | this.playMode = ExtendedAnimation.PlayMode.LOOP;
24 | }
25 |
26 | public CMediaAnimation(String file, int frameWidth, int frameHeight) {
27 | this(file, frameWidth, frameHeight, 0.1f, 0, Integer.MAX_VALUE, ExtendedAnimation.PlayMode.LOOP, true);
28 | }
29 |
30 | public CMediaAnimation(String file, int frameWidth, int frameHeight, float animationSpeed) {
31 | this(file, frameWidth, frameHeight, animationSpeed, 0, Integer.MAX_VALUE, ExtendedAnimation.PlayMode.LOOP, true);
32 | }
33 |
34 | public CMediaAnimation(String file, int frameWidth, int frameHeight, float animation_speed, int frameOffset, int frameLength) {
35 | this(file, frameWidth, frameHeight, animation_speed, frameOffset, frameLength, ExtendedAnimation.PlayMode.LOOP, true);
36 | }
37 |
38 | public CMediaAnimation(String filename, int frameWidth, int frameHeight, float animationSpeed, int frameOffset, int frameLength, ExtendedAnimation.PlayMode playMode) {
39 | this(filename, frameWidth, frameHeight, animationSpeed, frameOffset, frameLength, playMode, true);
40 | }
41 |
42 | public CMediaAnimation(String filename, int frameWidth, int frameHeight, float animationSpeed, int frameOffset, int frameLength, ExtendedAnimation.PlayMode playMode, boolean useAtlas) {
43 | super(filename, useAtlas);
44 | this.frameWidth = frameWidth;
45 | this.frameHeight = frameHeight;
46 | this.animationSpeed = animationSpeed;
47 | this.frameOffset = frameOffset;
48 | this.frameLength = frameLength;
49 | this.playMode = playMode;
50 | }
51 |
52 | public CMediaAnimation copy() {
53 | CMediaAnimation copy = new CMediaAnimation();
54 | copy.copyFields(this);
55 | copy.frameWidth = this.frameWidth;
56 | copy.frameHeight = this.frameHeight;
57 | copy.animationSpeed = this.animationSpeed;
58 | copy.frameOffset = this.frameOffset;
59 | copy.frameLength = this.frameLength;
60 | copy.playMode = this.playMode;
61 | return copy;
62 | }
63 |
64 | @Override
65 | public boolean equals(Object o) {
66 | if (o == null || getClass() != o.getClass()) return false;
67 | if (!super.equals(o)) return false;
68 |
69 | CMediaAnimation that = (CMediaAnimation) o;
70 | return frameWidth == that.frameWidth && frameHeight == that.frameHeight && Float.compare(animationSpeed, that.animationSpeed) == 0 && frameOffset == that.frameOffset && frameLength == that.frameLength && playMode == that.playMode;
71 | }
72 |
73 | @Override
74 | public int hashCode() {
75 | int result = super.hashCode();
76 | result = 31 * result + frameWidth;
77 | result = 31 * result + frameHeight;
78 | result = 31 * result + Float.hashCode(animationSpeed);
79 | result = 31 * result + frameOffset;
80 | result = 31 * result + frameLength;
81 | result = 31 * result + playMode.hashCode();
82 | return result;
83 | }
84 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaArray.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 |
5 | public final class CMediaArray extends CMediaSprite implements Serializable {
6 | public int frameWidth;
7 | public int frameHeight;
8 | public int frameOffset;
9 | public int frameLength;
10 |
11 | public CMediaArray() {
12 | super();
13 | this.frameWidth = 0;
14 | this.frameHeight = 0;
15 | this.frameOffset = 0;
16 | this.frameLength = Integer.MAX_VALUE;
17 | }
18 |
19 | public CMediaArray(String file, int frameWidth, int frameHeight) {
20 | this(file, frameWidth, frameHeight, 0, Integer.MAX_VALUE, true);
21 | }
22 |
23 | public CMediaArray(String file, int frameWidth, int frameHeight, int frameOffset, int frameLength) {
24 | this(file, frameWidth, frameHeight, frameOffset, frameLength, true);
25 | }
26 |
27 | public CMediaArray(String file, int frameWidth, int frameHeight, int frameOffset, int frameLength, boolean useAtlas) {
28 | super(file, useAtlas);
29 | this.frameWidth = frameWidth;
30 | this.frameHeight = frameHeight;
31 | this.frameOffset = frameOffset;
32 | this.frameLength = frameLength;
33 | }
34 |
35 | public CMediaArray copy() {
36 | CMediaArray copy = new CMediaArray();
37 | copy.copyFields(this);
38 | copy.frameWidth = this.frameWidth;
39 | copy.frameHeight = this.frameHeight;
40 | copy.frameOffset = this.frameOffset;
41 | copy.frameLength = this.frameLength;
42 | return copy;
43 | }
44 |
45 | @Override
46 | public boolean equals(Object o) {
47 | if (o == null || getClass() != o.getClass()) return false;
48 | if (!super.equals(o)) return false;
49 |
50 | CMediaArray that = (CMediaArray) o;
51 | return frameWidth == that.frameWidth && frameHeight == that.frameHeight && frameOffset == that.frameOffset && frameLength == that.frameLength;
52 | }
53 |
54 | @Override
55 | public int hashCode() {
56 | int result = super.hashCode();
57 | result = 31 * result + frameWidth;
58 | result = 31 * result + frameHeight;
59 | result = 31 * result + frameOffset;
60 | result = 31 * result + frameLength;
61 | return result;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaFont.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 | import java.util.Arrays;
5 | import java.util.Objects;
6 |
7 | public final class CMediaFont extends CMedia implements Serializable {
8 | public boolean markupEnabled;
9 | public CMediaFontOutline outline;
10 | public CMediaFontSymbol[] symbols;
11 | public boolean useAtlas;
12 |
13 | public CMediaFont() {
14 | super();
15 | this.markupEnabled = true;
16 | this.outline = null;
17 | this.symbols = new CMediaFontSymbol[]{};
18 | this.useAtlas = true;
19 | }
20 |
21 | public CMediaFont(String file) {
22 | this(file, true, null, null);
23 | }
24 |
25 | public CMediaFont(String file, boolean markupEnabled) {
26 | this(file, markupEnabled, null, null);
27 | }
28 |
29 | public CMediaFont(String file, boolean markupEnabled, CMediaFontSymbol[] symbols) {
30 | this(file, markupEnabled, symbols, null, true);
31 | }
32 |
33 | public CMediaFont(String filename, boolean markupEnabled, CMediaFontSymbol[] symbols, CMediaFontOutline outline) {
34 | this(filename, markupEnabled, symbols, outline, true);
35 | }
36 |
37 | public CMediaFont(String filename, boolean markupEnabled, CMediaFontSymbol[] symbols, CMediaFontOutline outline, boolean useAtlas) {
38 | super(filename);
39 | this.markupEnabled = markupEnabled;
40 | this.useAtlas = useAtlas;
41 | if (symbols != null) {
42 | this.symbols = new CMediaFontSymbol[symbols.length];
43 | for (int i = 0; i < symbols.length; i++)
44 | this.symbols[i] = symbols[i].copy();
45 | } else {
46 | this.symbols = new CMediaFontSymbol[0];
47 | }
48 |
49 | if (outline != null) {
50 | this.outline = new CMediaFontOutline(outline.color, outline.directions, outline.withSymbols, outline.outlineOnly);
51 | } else {
52 | this.outline = null;
53 | }
54 | }
55 |
56 | public CMediaFont copy(){
57 | CMediaFont copy = new CMediaFont();
58 | copy.copyFields(this);
59 | copy.markupEnabled = this.markupEnabled;
60 | copy.outline = this.outline.copy();
61 | copy.symbols = new CMediaFontSymbol[this.symbols.length];
62 | for(int i=0;i < this.symbols.length;i++)
63 | copy.symbols[i] = this.symbols[i].copy();
64 | copy.useAtlas = this.useAtlas;
65 | return copy;
66 | }
67 |
68 | @Override
69 | public boolean equals(Object o) {
70 | if (o == null || getClass() != o.getClass()) return false;
71 | if (!super.equals(o)) return false;
72 |
73 | CMediaFont that = (CMediaFont) o;
74 | return markupEnabled == that.markupEnabled && Objects.equals(outline, that.outline) && Arrays.equals(symbols, that.symbols);
75 | }
76 |
77 | @Override
78 | public int hashCode() {
79 | int result = super.hashCode();
80 | result = 31 * result + Boolean.hashCode(markupEnabled);
81 | result = 31 * result + Objects.hashCode(outline);
82 | result = 31 * result + Arrays.hashCode(symbols);
83 | return result;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaFontArraySymbol.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.util.Arrays;
4 |
5 | public final class CMediaFontArraySymbol extends CMediaFontSymbol {
6 | public int[] ids;
7 | public int regionWidth;
8 | public int regionHeight;
9 | public int frameOffset;
10 | public int frameLength;
11 |
12 | public CMediaFontArraySymbol() {
13 | super();
14 | this.ids = new int[]{};
15 | this.regionWidth = 0;
16 | this.regionHeight = 0;
17 | this.frameOffset = 0;
18 | this.frameLength = 0;
19 | }
20 |
21 | public CMediaFontArraySymbol(int[] ids, String file, int y_offset, int x_advance, int regionWidth, int regionHeight) {
22 | this(ids, file, y_offset, x_advance,regionWidth,regionHeight, 0, Integer.MAX_VALUE);
23 | }
24 |
25 | public CMediaFontArraySymbol(int[] ids, String file, int y_offset, int x_advance, int regionWidth, int regionHeight, int frameOffset, int frameLength) {
26 | super(file, y_offset, x_advance);
27 | if(ids != null){
28 | this.ids = new int[ids.length];
29 | System.arraycopy(ids,0,this.ids,0,ids.length);
30 | }else{
31 | this.ids= new int[]{};
32 | }
33 | this.regionWidth = regionWidth;
34 | this.regionHeight = regionHeight;
35 | this.frameOffset = frameOffset;
36 | this.frameLength = frameLength;
37 | }
38 |
39 | public CMediaFontArraySymbol copy(){
40 | CMediaFontArraySymbol copy = new CMediaFontArraySymbol();
41 | copy.copyFields(this);
42 | copy.ids = new int[this.ids.length];
43 | for(int i=0;i cMediaFontArraySymbol.copy();
26 | case CMediaFontSingleSymbol cMediaFontSingleSymbol -> cMediaFontSingleSymbol.copy();
27 | };
28 | return copy;
29 | }
30 |
31 | protected void copyFields(CMediaFontSymbol copyFrom){
32 | this.file = copyFrom.file;
33 | this.y_offset = copyFrom.y_offset;
34 | this.x_advance = copyFrom.x_advance;
35 | }
36 |
37 | @Override
38 | public boolean equals(Object object) {
39 | if (object == null || getClass() != object.getClass()) return false;
40 |
41 | CMediaFontSymbol that = (CMediaFontSymbol) object;
42 | return y_offset == that.y_offset && x_advance == that.x_advance && Objects.equals(file, that.file);
43 | }
44 |
45 | @Override
46 | public int hashCode() {
47 | int result = Objects.hashCode(file);
48 | result = 31 * result + y_offset;
49 | result = 31 * result + x_advance;
50 | return result;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaImage.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 |
5 | public final class CMediaImage extends CMediaSprite implements Serializable {
6 |
7 | public CMediaImage(){
8 | super();
9 | }
10 |
11 | public CMediaImage(String filename) {
12 | this(filename, true);
13 | }
14 |
15 | public CMediaImage(String filename, boolean useAtlas) {
16 | super(filename, useAtlas);
17 | }
18 |
19 | public CMediaImage copy(){
20 | CMediaImage copy = new CMediaImage();
21 | copy.copyFields(this);
22 | return copy;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaMusic.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 |
5 | public final class CMediaMusic extends CMediaSound implements Serializable {
6 |
7 | public CMediaMusic() {
8 | super();
9 | }
10 |
11 | public CMediaMusic(String filename) {
12 | super(filename);
13 | }
14 |
15 | public CMediaMusic copy(){
16 | CMediaMusic copy = new CMediaMusic();
17 | return copy;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaSound.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 |
5 | public sealed abstract class CMediaSound extends CMedia implements Serializable permits CMediaSoundEffect, CMediaMusic {
6 |
7 | public CMediaSound() {
8 | super();
9 | }
10 |
11 | public CMediaSound(String filename) {
12 | super(filename);
13 | }
14 |
15 | public CMediaSound copy() {
16 | CMediaSound copy = switch (this) {
17 | case CMediaMusic cMediaMusic -> cMediaMusic.copy();
18 | case CMediaSoundEffect cMediaSoundEffect -> cMediaSoundEffect.copy();
19 | };
20 | return copy;
21 | }
22 |
23 | protected void copyFields(CMediaSound copyFrom) {
24 | super.copyFields(copyFrom);
25 | }
26 |
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaSoundEffect.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 |
5 | public final class CMediaSoundEffect extends CMediaSound implements Serializable {
6 |
7 | public CMediaSoundEffect(){
8 | super();
9 | }
10 |
11 | public CMediaSoundEffect(String filename) {
12 | super(filename);
13 | }
14 |
15 | public CMediaSoundEffect copy(){
16 | CMediaSoundEffect copy = new CMediaSoundEffect();
17 | copy.copyFields(this);
18 | return copy;
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/CMediaSprite.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | import java.io.Serializable;
4 |
5 | public sealed abstract class CMediaSprite extends CMedia implements Serializable permits CMediaImage, CMediaArray, CMediaAnimation {
6 |
7 | public boolean useAtlas;
8 |
9 | public CMediaSprite(){
10 | super();
11 | this.useAtlas = true;
12 | }
13 |
14 |
15 | public CMediaSprite(String filename, boolean useAtlas) {
16 | super(filename);
17 | this.useAtlas = useAtlas;
18 | }
19 |
20 | public CMediaSprite copy(){
21 | CMediaSprite copy = switch (this){
22 | case CMediaAnimation cMediaAnimation -> cMediaAnimation.copy();
23 | case CMediaArray cMediaArray -> cMediaArray.copy();
24 | case CMediaImage cMediaImage -> cMediaImage.copy();
25 | };
26 | return copy;
27 | }
28 |
29 | protected void copyFields(CMediaSprite copyFrom){
30 | super.copyFields(copyFrom);
31 | this.useAtlas = copyFrom.useAtlas;
32 | }
33 |
34 | @Override
35 | public boolean equals(Object object) {
36 | if (object == null || getClass() != object.getClass()) return false;
37 | if (!super.equals(object)) return false;
38 |
39 | CMediaSprite that = (CMediaSprite) object;
40 | return useAtlas == that.useAtlas;
41 | }
42 |
43 | @Override
44 | public int hashCode() {
45 | int result = super.hashCode();
46 | result = 31 * result + Boolean.hashCode(useAtlas);
47 | return result;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/LoadProgress.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | public interface LoadProgress {
4 |
5 | void onLoadStep(String name, int step, int stepsMax);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/media/OUTLINE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.media;
2 |
3 | public class OUTLINE {
4 | public static final int UP = 1;
5 | public static final int DOWN = 2;
6 | public static final int LEFT = 4;
7 | public static final int RIGHT = 8;
8 | public static final int LEFT_UP = 16;
9 | public static final int RIGHT_UP = 32;
10 | public static final int RIGHT_DOWN = 64;
11 | public static final int LEFT_DOWN = 128;
12 |
13 | public static final int ALL = UP | DOWN | LEFT | RIGHT | LEFT_UP | RIGHT_UP | RIGHT_DOWN | LEFT_DOWN;
14 | public static final int SHADOW = RIGHT | RIGHT_DOWN | DOWN;
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/rendering/BaseColorTweakRenderer.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.rendering;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.graphics.glutils.ShaderProgram;
5 |
6 | public abstract class BaseColorTweakRenderer extends BaseRenderer {
7 | public static final String COLOR_ATTRIBUTE = "a_color";
8 | public static final String TWEAK_ATTRIBUTE = "a_tweak";
9 |
10 | protected float tweak;
11 | protected float tweak_save;
12 | protected float tweak_reset;
13 |
14 | protected float color;
15 | protected float color_save;
16 | protected float color_reset;
17 |
18 | public BaseColorTweakRenderer(final int maxVertexes, final ShaderProgram defaultShader, final boolean printRenderCalls) {
19 | super(maxVertexes, defaultShader, printRenderCalls);
20 |
21 | this.tweak_reset = colorPackedRGBA(0f, 0f, 0f, 0.0f);
22 | this.tweak_save = tweak_reset;
23 | this.tweak = tweak_reset;
24 |
25 | this.color_reset = colorPackedRGBA(0.5f, 0.5f, 0.5f, 1f);
26 | this.color_save = color_reset;
27 | this.color = color_reset;
28 | }
29 |
30 | @Override
31 | public void saveState() {
32 | super.saveState();
33 | this.color_save = this.color;
34 | this.tweak_save = this.tweak;
35 | }
36 |
37 |
38 | public void loadState() {
39 | super.loadState();
40 | setPackedColor(this.color_save);
41 | setPackedTweak(this.tweak_save);
42 | }
43 |
44 | public void setColor(Color color) {
45 | this.color = colorPackedRGBA(color.r, color.g, color.b, color.a);
46 | }
47 |
48 | public void setColor(Color color, float alpha) {
49 | this.color = colorPackedRGBA(color.r, color.g, color.b, alpha);
50 | }
51 |
52 | public void setColor(final float r, final float g, final float b, final float alpha) {
53 | this.color = colorPackedRGBA(r, g, b, alpha);
54 | }
55 |
56 | public void setPackedColor(final float color) {
57 | this.color = color;
58 | }
59 |
60 | public Color getColor() {
61 | Color.abgr8888ToColor(tempColor, color);
62 | return tempColor;
63 | }
64 |
65 | public void setColorReset() {
66 | setPackedColor(color_reset);
67 | }
68 |
69 | public float getPackedColor() {
70 | return this.color;
71 | }
72 |
73 | public void setTweak(final float t1, final float t2, final float t3, final float t4) {
74 | tweak = colorPackedRGBA(t1, t2, t3, t4);
75 | }
76 |
77 | public void setPackedTweak(final float tweak) {
78 | this.tweak = tweak;
79 | }
80 |
81 | public float getPackedTweak() {
82 | return this.tweak;
83 | }
84 |
85 | public Color getTweak() {
86 | Color.abgr8888ToColor(tempColor, tweak);
87 | return tempColor;
88 | }
89 |
90 | public void setTweakReset() {
91 | setPackedTweak(tweak_reset);
92 | }
93 |
94 | public void setAllReset() {
95 | setTweakReset();
96 | setColorReset();
97 | setBlendFunctionReset();
98 | }
99 |
100 | public void setColorResetValues(final float r, final float g, final float b, final float a) {
101 | this.color_reset = colorPackedRGBA(r, g, b, a);
102 | this.setColorReset();
103 | }
104 |
105 | public void setTweakResetValues(final float h, final float s, final float l, final float c) {
106 | this.tweak_reset = colorPackedRGBA(h, s, l, c);
107 | this.setTweakReset();
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/rendering/ExtendedAnimation.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.rendering;
2 |
3 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
4 | import com.badlogic.gdx.math.MathUtils;
5 | import com.badlogic.gdx.utils.Array;
6 |
7 | /**
8 | * Reflection Free Alternative to Libgdx Animation, supporting a stateTimeOffset
9 | */
10 | public final class ExtendedAnimation {
11 |
12 | private final TextureRegion[] keyFrames;
13 | private float animationDuration;
14 | private float animationSpeed;
15 | private float stateTimeOffset;
16 | private int lastFrameNumber;
17 | private float lastStateTime;
18 | private PlayMode playMode;
19 |
20 | public enum PlayMode {
21 | NORMAL, REVERSED, LOOP, LOOP_REVERSED, LOOP_PINGPONG, LOOP_RANDOM,
22 | }
23 |
24 | public ExtendedAnimation(ExtendedAnimation other) {
25 | this.keyFrames = new TextureRegion[other.keyFrames.length];
26 | for (int i = 0; i < this.keyFrames.length; i++)
27 | this.keyFrames[i] = new TextureRegion(other.keyFrames[i]);
28 | this.animationDuration = other.animationDuration;
29 | this.animationSpeed = other.animationSpeed;
30 | this.stateTimeOffset = other.stateTimeOffset;
31 | this.lastFrameNumber = other.lastFrameNumber;
32 | this.lastStateTime = other.lastStateTime;
33 | this.playMode = other.playMode;
34 | }
35 |
36 | public ExtendedAnimation(float animationSpeed, TextureRegion[] keyFrames, PlayMode playMode) {
37 | this.keyFrames = new TextureRegion[keyFrames.length];
38 | for (int i = 0; i < keyFrames.length; i++)
39 | this.keyFrames[i] = new TextureRegion(keyFrames[i]);
40 | this.playMode = playMode;
41 | this.animationSpeed = animationSpeed;
42 | this.animationDuration = this.keyFrames.length * animationSpeed;
43 | this.stateTimeOffset = 0;
44 | }
45 |
46 | public ExtendedAnimation(float animationSpeed, Array keyFrames, PlayMode playMode) {
47 | this.keyFrames = new TextureRegion[keyFrames.size];
48 | for (int i = 0; i < keyFrames.size; i++)
49 | this.keyFrames[i] = keyFrames.get(i);
50 |
51 | this.playMode = playMode;
52 | this.animationSpeed = animationSpeed;
53 | this.animationDuration = this.keyFrames.length * animationSpeed;
54 | this.stateTimeOffset = 0;
55 | }
56 |
57 | public TextureRegion getKeyFrame(float stateTime) {
58 | return keyFrames[getKeyFrameIndex(stateTime)];
59 | }
60 |
61 | public int getKeyFrameIndex(float stateTime) {
62 | if (keyFrames.length == 1) return 0;
63 |
64 | stateTime = Math.max(stateTime - this.stateTimeOffset, 0);
65 |
66 | int frameNumber = (int) (stateTime / animationSpeed);
67 | switch (playMode) {
68 | case NORMAL:
69 | frameNumber = Math.min(keyFrames.length - 1, frameNumber);
70 | break;
71 | case LOOP:
72 | frameNumber = frameNumber % keyFrames.length;
73 | break;
74 | case LOOP_PINGPONG:
75 | frameNumber = frameNumber % ((keyFrames.length * 2) - 2);
76 | if (frameNumber >= keyFrames.length)
77 | frameNumber = keyFrames.length - 2 - (frameNumber - keyFrames.length);
78 | break;
79 | case LOOP_RANDOM:
80 | int lastFrameNumber = (int) ((lastStateTime) / animationSpeed);
81 | if (lastFrameNumber != frameNumber) {
82 | frameNumber = MathUtils.random(keyFrames.length - 1);
83 | } else {
84 | frameNumber = this.lastFrameNumber;
85 | }
86 | break;
87 | case REVERSED:
88 | frameNumber = Math.max(keyFrames.length - frameNumber - 1, 0);
89 | break;
90 | case LOOP_REVERSED:
91 | frameNumber = frameNumber % keyFrames.length;
92 | frameNumber = keyFrames.length - frameNumber - 1;
93 | break;
94 | }
95 |
96 | lastFrameNumber = frameNumber;
97 | lastStateTime = stateTime;
98 | return frameNumber;
99 | }
100 |
101 | public PlayMode getPlayMode() {
102 | return playMode;
103 | }
104 |
105 | public void setPlayMode(PlayMode playMode) {
106 | this.playMode = playMode;
107 | }
108 |
109 | public boolean isAnimationFinished(float stateTime) {
110 | int frameNumber = (int) (stateTime / animationSpeed);
111 | return keyFrames.length - 1 < frameNumber;
112 | }
113 |
114 | public void setAnimationSpeed(float animationSpeed) {
115 | this.animationSpeed = animationSpeed;
116 | this.animationDuration = keyFrames.length * animationSpeed;
117 | }
118 |
119 | public float getAnimationSpeed() {
120 | return animationSpeed;
121 | }
122 |
123 | public float getAnimationDuration() {
124 | return animationDuration;
125 | }
126 |
127 | public float getStateTimeOffset() {
128 | return stateTimeOffset;
129 | }
130 |
131 | public void setStateTimeOffset(float stateTimeOffset) {
132 | this.stateTimeOffset = stateTimeOffset;
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/rendering/NestedFrameBuffer.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.rendering;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.graphics.GL20;
5 | import com.badlogic.gdx.graphics.GL32;
6 | import com.badlogic.gdx.graphics.Pixmap;
7 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
8 | import com.badlogic.gdx.graphics.glutils.FrameBuffer;
9 |
10 | import java.nio.ByteBuffer;
11 | import java.nio.ByteOrder;
12 | import java.nio.IntBuffer;
13 |
14 | /**
15 | * An implementation of Framebuffer allows nesting.
16 | * Adapted from: https://github.com/crykn/libgdx-screenmanager/wiki/Custom-FrameBuffer-implementation
17 | */
18 | public class NestedFrameBuffer extends FrameBuffer {
19 | private static final String ERROR_END_BEGIN = "NestedFrameBuffer.end must be called before begin.";
20 | private static final String ERROR_BEGIN_END = "NestedFrameBuffer.begin must be called before end.";
21 | private int[] previousViewport;
22 | private boolean isBound;
23 | private TextureRegion textureRegionFlippedCache;
24 | private final IntBuffer intBuffer;
25 | private int[] getViewPortCache;
26 | private int previousFBOHandle;
27 | private int getBoundFBOCache;
28 |
29 | public NestedFrameBuffer(Pixmap.Format format, int width, int height) {
30 | this(format, width, height, false, false);
31 | }
32 |
33 | public NestedFrameBuffer(Pixmap.Format format, int width, int height, boolean hasDepth) {
34 | this(format, width, height, hasDepth, false);
35 | }
36 |
37 | public NestedFrameBuffer(Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil) {
38 | super(format, width, height, hasDepth, hasStencil);
39 | this.isBound = false;
40 | this.previousFBOHandle = -1;
41 | this.previousViewport = null;
42 | this.intBuffer = ByteBuffer
43 | .allocateDirect(16 * Integer.BYTES).order(ByteOrder.nativeOrder())
44 | .asIntBuffer();
45 | this.getBoundFBOCache = -1;
46 | this.getViewPortCache = null;
47 | this.textureRegionFlippedCache = null;
48 | }
49 |
50 |
51 | private int getBoundFboHandle() {
52 | if(this.getBoundFBOCache != -1) return this.getBoundFBOCache;
53 | Gdx.gl.glGetIntegerv(GL32.GL_FRAMEBUFFER_BINDING, this.intBuffer);
54 | this.getBoundFBOCache = this.intBuffer.get(0);
55 | return this.getBoundFBOCache;
56 | }
57 |
58 | private int[] getViewport() {
59 | if(this.getViewPortCache != null) return this.getViewPortCache;
60 | this.getViewPortCache = new int[4];
61 | IntBuffer intBuf = intBuffer;
62 | Gdx.gl.glGetIntegerv(GL32.GL_VIEWPORT, intBuf);
63 | this.getViewPortCache[0] = intBuf.get(0);
64 | this.getViewPortCache[1] = intBuf.get(1);
65 | this.getViewPortCache[2] = intBuf.get(2);
66 | this.getViewPortCache[3] = intBuf.get(3);
67 | return this.getViewPortCache;
68 | }
69 |
70 |
71 | public void beginGlClear(){
72 | this.begin();
73 | Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
74 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
75 | }
76 |
77 | @Override
78 | public void begin() {
79 | if (isBound) throw new RuntimeException(ERROR_BEGIN_END);
80 | isBound = true;
81 |
82 | previousFBOHandle = getBoundFboHandle();
83 | bind();
84 |
85 | previousViewport = getViewport();
86 | setFrameBufferViewport();
87 | }
88 |
89 | @Deprecated
90 | @Override
91 | public void bind() {
92 | Gdx.gl.glBindFramebuffer(GL32.GL_FRAMEBUFFER, framebufferHandle);
93 | }
94 |
95 | @Override
96 | public void end() {
97 | end(previousViewport[0], previousViewport[1], previousViewport[2],
98 | previousViewport[3]);
99 | }
100 |
101 | @Override
102 | public void end(int x, int y, int width, int height) {
103 | if (!isBound) throw new RuntimeException(ERROR_END_BEGIN);
104 | isBound = false;
105 | Gdx.gl.glBindFramebuffer(GL32.GL_FRAMEBUFFER, previousFBOHandle);
106 | Gdx.gl.glViewport(x, y, width, height);
107 | }
108 |
109 | @Override
110 | protected void build() {
111 | int previousFBOHandle = getBoundFboHandle();
112 | super.build();
113 | Gdx.gl.glBindFramebuffer(GL32.GL_FRAMEBUFFER, previousFBOHandle);
114 | }
115 |
116 | public boolean isBound() {
117 | return isBound;
118 | }
119 |
120 | public void resetCaches(){
121 | this.getViewPortCache = null;
122 | this.textureRegionFlippedCache = null;
123 | this.getBoundFBOCache = -1;
124 | }
125 |
126 |
127 | public TextureRegion getFlippedTextureRegion(){
128 | if(this.textureRegionFlippedCache == null){
129 | this.textureRegionFlippedCache = new TextureRegion(this.getColorBufferTexture());
130 | this.textureRegionFlippedCache.flip(false,true);
131 | }
132 | return this.textureRegionFlippedCache;
133 | }
134 |
135 | @Override
136 | public void dispose() {
137 | super.dispose();
138 | }
139 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/rendering/PixelPerfectViewport.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.rendering;
2 |
3 | import com.badlogic.gdx.graphics.Camera;
4 | import com.badlogic.gdx.math.MathUtils;
5 | import com.badlogic.gdx.utils.viewport.FitViewport;
6 |
7 | public class PixelPerfectViewport extends FitViewport {
8 | private final int iRateMin;
9 | public PixelPerfectViewport(float worldWidth, float worldHeight, Camera camera, int iRateMin) {
10 | super(worldWidth, worldHeight, camera);
11 | this.iRateMin = iRateMin;
12 | }
13 | @Override
14 | public void update(int screenWidth, int screenHeight, boolean centerCamera) {
15 |
16 | // get the min screen/world rate from width and height
17 | float wRate = screenWidth / getWorldWidth();
18 | float hRate = screenHeight / getWorldHeight();
19 | float rate = Math.min(wRate, hRate);
20 |
21 | // round it down and limit to one
22 | int iRate = Math.max(1, MathUtils.floor(rate));
23 | if(iRate < iRateMin) iRate = iRateMin;
24 |
25 | // compute rounded viewport dimension
26 | int viewportWidth = (int)getWorldWidth() * iRate;
27 | int viewportHeight = (int)getWorldHeight() * iRate;
28 |
29 | // Center.
30 | setScreenBounds((screenWidth - viewportWidth) / 2, (screenHeight - viewportHeight) / 2, viewportWidth, viewportHeight);
31 |
32 | apply(centerCamera);
33 | }
34 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/PixelUILaunchConfig.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils;
2 |
3 | public final class PixelUILaunchConfig {
4 |
5 | public String appTile = "Pixel UI Game";
6 | public int resolutionWidth = 320;
7 | public int resolutionHeight = 240;
8 | public String iconPath = null;
9 | public GLEmulation windowsGLEmulation = GLEmulation.GL32_VULKAN;
10 | public GLEmulation linuxGLEmulation = GLEmulation.GL32_VULKAN;
11 | public GLEmulation macOSGLEmulation = GLEmulation.GL32_OPENGL;
12 | public int fps = 60;
13 | public int idleFPS = 60;
14 | public boolean vSync = false;
15 | public int r,g,b,a = 8;
16 | public int depth = 16;
17 | public int stencil = 0;
18 | public int samples = 0;
19 | public boolean resizeAble = true;
20 | public boolean decorated = true;
21 | public boolean maximized = true;
22 |
23 | public PixelUILaunchConfig() {
24 | }
25 |
26 | public enum GLEmulation {
27 | GL32_VULKAN,
28 | GL32_OPENGL
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/appengine/AppEngine.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.appengine;
2 |
3 | import com.badlogic.gdx.utils.Disposable;
4 | import com.badlogic.gdx.utils.Queue;
5 |
6 | /**
7 | * Modifies Data Structure 1 update step at a time.
8 | * Sends input to adapter & gathers outputs using object pooling.
9 | */
10 | public class AppEngine, D extends Object> implements Disposable {
11 |
12 | private static final Object[] RESET_OBJECT = new Object[AppEngineIO.PARAMETERS_MAX];
13 | private static final int[] RESET_INT = new int[AppEngineIO.PARAMETERS_MAX];
14 | private static final long[] RESET_LONG = new long[AppEngineIO.PARAMETERS_MAX];
15 | private static final float[] RESET_FLOAT = new float[AppEngineIO.PARAMETERS_MAX];
16 | private static final double[] RESET_DOUBLE = new double[AppEngineIO.PARAMETERS_MAX];
17 | private static final boolean[] RESET_BOOLEAN = new boolean[AppEngineIO.PARAMETERS_MAX];
18 |
19 | static {
20 | for (int i = 0; i < AppEngineIO.PARAMETERS_MAX; i++) {
21 | RESET_OBJECT[i] = null;
22 | RESET_INT[i] = 0;
23 | RESET_LONG[i] = 0l;
24 | RESET_FLOAT[i] = 0;
25 | RESET_DOUBLE[i] = 0;
26 | RESET_BOOLEAN[i] = false;
27 | }
28 | }
29 |
30 | private long ticks;
31 | private AppEngineIO lastOutput;
32 |
33 | private final A adapter;
34 | private final D data;
35 | private final Queue inputs;
36 | private final Queue outputs;
37 | private final Queue engineIOPool;
38 | private final AppEngineOutputQueue appEngineOutputQueue = new AppEngineOutputQueue() {
39 | @Override
40 | public synchronized void addOutput(AppEngineIO output) {
41 | output.locked = true;
42 | outputs.addLast(output);
43 | }
44 |
45 | public synchronized AppEngineIO newIO(int type) {
46 | AppEngineIO appEngineIO = getUnlockedUIFromPool(type);
47 | return appEngineIO;
48 | }
49 |
50 | };
51 |
52 | public AppEngine(A adapter, D data) {
53 | final String errorMessageNull = "Cannot initialize AppEngine: %s is null";
54 | if (data == null) throw new RuntimeException(String.format(errorMessageNull, "data"));
55 | if (adapter == null) throw new RuntimeException(String.format(errorMessageNull, "adapter"));
56 |
57 | this.lastOutput = null;
58 | this.ticks = 0;
59 |
60 | this.data = data;
61 | this.inputs = new Queue<>();
62 | this.outputs = new Queue<>();
63 | this.engineIOPool = new Queue<>();
64 | this.adapter = adapter;
65 |
66 | this.adapter.init(this.data, this.appEngineOutputQueue);
67 | }
68 |
69 | public long getTicks() {
70 | return ticks;
71 | }
72 |
73 | private AppEngineIO getUnlockedUIFromPool(int type) {
74 | AppEngineIO appEngineIO = engineIOPool.isEmpty() ? new AppEngineIO() : engineIOPool.removeFirst();
75 | appEngineIO.locked = false;
76 | appEngineIO.type = type;
77 | appEngineIO.readIndex = 0;
78 | appEngineIO.writeIndex = 0;
79 | System.arraycopy(RESET_OBJECT, 0, appEngineIO.objectStack, 0, AppEngineIO.PARAMETERS_MAX);
80 | System.arraycopy(RESET_INT, 0, appEngineIO.intStack, 0, AppEngineIO.PARAMETERS_MAX);
81 | System.arraycopy(RESET_FLOAT, 0, appEngineIO.floatStack, 0, AppEngineIO.PARAMETERS_MAX);
82 | return appEngineIO;
83 | }
84 |
85 | public boolean outputAvailable() {
86 | return !this.outputs.isEmpty();
87 | }
88 |
89 | public AppEngineIO processOutput() {
90 | if (lastOutput != null) engineIOPool.addLast(lastOutput);
91 | if (outputAvailable()) {
92 | lastOutput = outputs.removeFirst();
93 | return lastOutput;
94 | } else {
95 | lastOutput = null;
96 | return null;
97 | }
98 | }
99 |
100 | public void clearOutputs() {
101 | for(int i=0;i {
4 | void init(D data, AppEngineOutputQueue outputQueue);
5 | default void beforeInputs() {}
6 | void processInput(AppEngineIO engineIO);
7 | void update();
8 | void shutdown();
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/appengine/AppEngineOutputQueue.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.appengine;
2 |
3 | public interface AppEngineOutputQueue {
4 | void addOutput(AppEngineIO appEngineIO);
5 | AppEngineIO newIO(int type);
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/appengine/AppEngineParameter.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.appengine;
2 |
3 | public abstract class AppEngineParameter {
4 | }
5 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/misc/IntValueWatcher.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.misc;
2 |
3 | public class IntValueWatcher {
4 | private int value = 0;
5 | private int difference;
6 | private boolean initialized;
7 |
8 | public IntValueWatcher() {
9 | super();
10 | }
11 |
12 | public int value() {
13 | return value;
14 | }
15 |
16 | public void setValue(int value) {
17 | this.difference = value - this.value;
18 | this.value = value;
19 | }
20 |
21 | public int delta() {
22 | return difference;
23 | }
24 |
25 | public boolean hasValueChanged(int currentValue) {
26 | if (!initialized || this.value != currentValue) {
27 | this.setValue(currentValue);
28 | this.initialized = true;
29 | return true;
30 | }
31 | return false;
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/misc/JSONIncludeParser.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.misc;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.files.FileHandle;
5 | import com.badlogic.gdx.utils.Array;
6 | import com.badlogic.gdx.utils.IntArray;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.nio.file.Files;
11 | import java.nio.file.Path;
12 |
13 |
14 | public class JSONIncludeParser {
15 |
16 | private static final String INCLUDE = "//INCLUDE ";
17 |
18 | private static final String INCLUDE_TRIM = "//INCLUDE_TRIM ";
19 |
20 | public enum InputFileMode {
21 | CLASSPATH,EXTERNAL
22 | }
23 |
24 |
25 | static final class IncludeInfo {
26 | public final String includeFile;
27 | public final boolean trim;
28 |
29 | IncludeInfo(String includeFile, boolean trim) {
30 | this.includeFile = includeFile;
31 | this.trim = trim;
32 | }
33 |
34 | public String includeFile() {
35 | return includeFile;
36 | }
37 |
38 | public boolean trim() {
39 | return trim;
40 | }
41 |
42 | }
43 |
44 | private static IncludeInfo findIncludeInfo(String line) {
45 | String prepare = line.trim();
46 | if (prepare.startsWith(INCLUDE)) {
47 | return new IncludeInfo(line.substring(INCLUDE.length()), false);
48 | } else if (prepare.startsWith(INCLUDE_TRIM)) {
49 | return new IncludeInfo(line.substring(INCLUDE_TRIM.length()), true);
50 | } else {
51 | return null;
52 | }
53 | }
54 |
55 |
56 | private static Array getFileContent(String basePath, String fileName, boolean include, boolean trimInclude, InputFileMode inputFileMode) throws IOException {
57 | Array lines = new Array<>();
58 | String fileContent = "";
59 | if (inputFileMode == InputFileMode.CLASSPATH) {
60 | FileHandle fileHandle = Gdx.files.internal(basePath + fileName);
61 | fileContent = fileHandle.readString();
62 | } else if (inputFileMode == InputFileMode.EXTERNAL) {
63 | fileContent = Files.readString(Path.of(basePath + fileName));
64 | }
65 | String[] fileContentSplit = fileContent.split(System.lineSeparator());
66 | for (int i = 0; i < fileContentSplit.length; i++) {
67 | String line = fileContentSplit[i].trim();
68 | if (!line.isEmpty()) lines.add(line);
69 | }
70 |
71 | if (include) {
72 | // Remove braces
73 | if (trimInclude) {
74 | lines.removeIndex(0);
75 | lines.pop();
76 | }
77 | // update of sub includes path
78 | for (int i = 0; i < lines.size; i++) {
79 | String line = lines.get(i);
80 | IncludeInfo includeInfo = findIncludeInfo(line);
81 | if (includeInfo != null) {
82 | String incFile = includeInfo.includeFile;
83 | String currentdir = new File(fileName).getParent();
84 | String incSyntax = includeInfo.trim ? INCLUDE_TRIM : INCLUDE;
85 | lines.set(i, incSyntax + currentdir + "\\" + incFile);
86 | }
87 |
88 | }
89 |
90 | }
91 | return lines;
92 | }
93 |
94 |
95 | public static String parseJSON(String jsonPath, InputFileMode inputFileMode) throws IOException {
96 | StringBuilder result = new StringBuilder();
97 |
98 | // Read File
99 | String basePath = "", fileName;
100 | File jsonFile = new File(jsonPath);
101 | if (jsonFile.getParent() != null) {
102 | basePath = jsonFile.getParent() + "\\";
103 | }
104 | fileName = jsonFile.getName();
105 |
106 | // Read Base File
107 | Array lines = getFileContent(basePath, fileName, false, false, inputFileMode);
108 |
109 | // Parse includes
110 | IntArray removeIndexes = new IntArray();
111 | for (int i = 0; i < lines.size; i++) {
112 | String line = lines.get(i);
113 |
114 | IncludeInfo includeInfo = findIncludeInfo(line);
115 | if (includeInfo != null) {
116 | lines.set(i, "");
117 | removeIndexes.add(i);
118 | Array includeLines = getFileContent(basePath, includeInfo.includeFile, true, includeInfo.trim, inputFileMode);
119 | if (includeLines.size > 0) {
120 | for (int i2 = includeLines.size - 1; i2 >= 0; i2--) {
121 | String incLine = includeLines.get(i2);
122 | lines.insert(i + 1, incLine);
123 | }
124 | }
125 | }
126 |
127 | }
128 |
129 | // remove empty
130 | while (!removeIndexes.isEmpty()) {
131 | lines.removeIndex(removeIndexes.removeIndex(removeIndexes.size - 1));
132 | }
133 |
134 | for (int i = 0; i < lines.size; i++) result.append(lines.get(i)).append(System.lineSeparator());
135 | return result.toString();
136 | }
137 |
138 |
139 | }
140 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/misc/cli/Hex2Float.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.misc.cli;
2 |
3 |
4 | /**
5 | * Created by Admin on 08.03.2019.
6 | */
7 | public class Hex2Float {
8 |
9 | public static void main(String[] args){
10 | final String arg = args.length >= 1 ? args[0] : "#333454";
11 | System.out.println(hex2Float(arg));
12 | }
13 |
14 | public static String hex2Float(String hex){
15 | if(hex.startsWith("#")) hex = hex.substring(1);
16 | byte[] bytes = toByteArray(hex);
17 | float c1 = Integer.parseInt(hex.substring(0,2),16)/255f;
18 | float c2 = Integer.parseInt(hex.substring(2,4),16)/255f;
19 | float c3 = Integer.parseInt(hex.substring(4,6),16)/255f;
20 | return c1+"f,"+c2+"f,"+c3+"f,1f";
21 |
22 | }
23 |
24 | public static byte[] toByteArray(String s) {
25 | int len = s.length();
26 | byte[] data = new byte[len / 2];
27 | for (int i = 0; i < len; i += 2) {
28 | data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
29 | + Character.digit(s.charAt(i+1), 16));
30 | }
31 | return data;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/misc/cli/Hex2FloatImage.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.misc.cli;
2 |
3 | import javax.imageio.ImageIO;
4 | import java.awt.datatransfer.Clipboard;
5 | import java.awt.datatransfer.ClipboardOwner;
6 | import java.awt.datatransfer.Transferable;
7 | import java.awt.image.BufferedImage;
8 | import java.io.File;
9 |
10 | public class Hex2FloatImage implements ClipboardOwner {
11 |
12 | public static void main(String[] args) throws Exception {
13 |
14 | new Hex2FloatImage().hex2FloatImage("D:\\Code\\waves\\dev\\watercolor.png");
15 |
16 | }
17 |
18 | public void hex2FloatImage(String path) throws Exception {
19 | BufferedImage image = ImageIO.read(new File(path));
20 |
21 | boolean color = true;
22 | int skip = 0;
23 | System.out.println("public enum WATER_COLOR {");
24 |
25 | int value = 1;
26 | for (int x = 0; x < image.getWidth(); x++) {
27 | int c = image.getRGB(x, 0);
28 | int red = (c & 0x00ff0000) >> 16;
29 | int green = (c & 0x0000ff00) >> 8;
30 | int blue = c & 0x000000ff;
31 | int alpha = (c >> 24) & 0xff;
32 |
33 |
34 | System.out.print("VALUE_"+(value++)+"("+(red/256f)+"f,"+(green/256f)+"f,"+(blue/256f)+"f,"+(alpha/256f)+"f)");
35 |
36 | if(x != image.getWidth()-1) System.out.print(",");
37 | skip++;
38 | if(skip >= 10){
39 | System.out.println();
40 | skip = 0;
41 | }
42 | }
43 |
44 | System.out.println(";");
45 | System.out.println("");
46 | System.out.println("");
47 | System.out.println("public final float r,g,b,a;");
48 | System.out.println("");
49 | System.out.println("WATER_COLOR(float r,float g, float b, float a){");
50 | System.out.println(" this.r = r;");
51 | System.out.println(" this.g = g;");
52 | System.out.println(" this.b = b;");
53 | System.out.println(" this.a = a;");
54 | System.out.println("}");
55 |
56 | System.out.println("}");
57 |
58 |
59 |
60 | }
61 |
62 | @Override
63 | public void lostOwnership(Clipboard clipboard, Transferable contents) {
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/ParticleUpdater.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles;
2 |
3 | import net.mslivo.pixelui.utils.particles.particles.Particle;
4 |
5 | public interface ParticleUpdater {
6 | default boolean updateParticle(Particle particle){
7 | return true;
8 | };
9 |
10 | default void resetParticleData(T particleData){
11 | return;
12 | };
13 | }
14 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/AnimationParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public final class AnimationParticle extends TextureBasedParticle {
4 |
5 | public float animationOffset;
6 | }
7 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/ArrayParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public final class ArrayParticle extends TextureBasedParticle {
4 | public int arrayIndex;
5 | }
6 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/EmptyParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public final class EmptyParticle extends Particle{
4 | }
5 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/ImageParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public final class ImageParticle extends TextureBasedParticle {
4 | }
5 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/Particle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public abstract sealed class Particle permits EmptyParticle, PrimitiveParticle, SpriteParticle {
4 | public float x, y;
5 | public float r, g, b, a;
6 | public boolean visible;
7 | public D data;
8 | }
9 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/PrimitiveParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public final class PrimitiveParticle extends Particle {
4 | public float[] vtx_x, vtx_y;
5 | public float[] vtx_r, vtx_g, vtx_b, vtx_a;
6 | public int numAdditionalVertexes;
7 | public int primitiveType;
8 | }
9 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/SpriteParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | public abstract sealed class SpriteParticle extends Particle permits TextParticle, TextureBasedParticle {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/TextParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | import net.mslivo.pixelui.media.CMediaFont;
4 |
5 | public final class TextParticle extends SpriteParticle {
6 | public boolean centerX, centerY;
7 | public CMediaFont font;
8 | public String text;
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/particles/particles/TextureBasedParticle.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.particles.particles;
2 |
3 | import net.mslivo.pixelui.media.CMediaSprite;
4 |
5 | public abstract sealed class TextureBasedParticle extends SpriteParticle permits AnimationParticle, ArrayParticle, ImageParticle {
6 | public CMediaSprite sprite;
7 | public float rotation, scaleX, scaleY;
8 | public float origin_x, origin_y;
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/SettingsEntry.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings;
2 |
3 | import java.util.Objects;
4 |
5 | public final class SettingsEntry {
6 | private final String name;
7 | private final String defaultValue;
8 | private final ValueValidator valueValidator;
9 |
10 | public SettingsEntry(String name, String defaultValue, ValueValidator valueValidator) {
11 | this.name = name;
12 | this.defaultValue = defaultValue;
13 | this.valueValidator = valueValidator;
14 | }
15 |
16 | public String name() {
17 | return name;
18 | }
19 |
20 | public String defaultValue() {
21 | return defaultValue;
22 | }
23 |
24 | public ValueValidator valueValidator() {
25 | return valueValidator;
26 | }
27 |
28 | @Override
29 | public boolean equals(Object obj) {
30 | if (obj == this) return true;
31 | if (obj == null || obj.getClass() != this.getClass()) return false;
32 | var that = (SettingsEntry) obj;
33 | return Objects.equals(this.name, that.name) &&
34 | Objects.equals(this.defaultValue, that.defaultValue) &&
35 | Objects.equals(this.valueValidator, that.valueValidator);
36 | }
37 |
38 | @Override
39 | public int hashCode() {
40 | return Objects.hash(name, defaultValue, valueValidator);
41 | }
42 |
43 | @Override
44 | public String toString() {
45 | return "SettingsEntry[" +
46 | "name=" + name + ", " +
47 | "defaultValue=" + defaultValue + ", " +
48 | "validateFunction=" + valueValidator + ']';
49 | }
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/SettingsException.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings;
2 |
3 | public class SettingsException extends RuntimeException {
4 |
5 | public SettingsException(Exception e){
6 | super(e);
7 | }
8 |
9 | public SettingsException(String message){
10 | super(message);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/SettingsPersistor.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings;
2 |
3 | import java.util.Properties;
4 |
5 | public interface SettingsPersistor {
6 | void saveSettings(String settingsFile, Properties properties);
7 |
8 | void loadSettings(String settingsFile, Properties properties);
9 | }
10 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/ValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings;
2 |
3 | public interface ValueValidator {
4 |
5 | boolean isValueValid(String value);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/persistor/PropertiesFilePersistor.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.persistor;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsException;
4 | import net.mslivo.pixelui.utils.settings.SettingsPersistor;
5 | import net.mslivo.pixelui.utils.Tools;
6 |
7 | import java.io.IOException;
8 | import java.nio.file.Files;
9 | import java.nio.file.Path;
10 | import java.util.Properties;
11 |
12 | public class PropertiesFilePersistor implements SettingsPersistor {
13 |
14 | private static final String EXTENSION = ".properties";
15 |
16 | @Override
17 | public void saveSettings(String settingsFile, Properties properties) {
18 | String fileString = settingsFile;
19 | if(!settingsFile.endsWith(EXTENSION)) fileString += EXTENSION;
20 |
21 | Path file = Path.of(fileString);
22 | try {
23 | if (Tools.File.makeSureDirectoryExists(file.getParent())) {
24 | properties.store(Files.newOutputStream(file), null);
25 | }
26 | } catch (IOException e) {
27 | throw new SettingsException(e);
28 | }
29 | }
30 |
31 | @Override
32 | public void loadSettings(String settingsFile, Properties properties) {
33 | String fileString = settingsFile;
34 | if(!settingsFile.endsWith(EXTENSION)) fileString += EXTENSION;
35 |
36 | Path file = Path.of(fileString);
37 | if (Files.exists(file) && Files.isRegularFile(file)) {
38 | try {
39 | properties.load(Files.newInputStream(file));
40 | } catch (IOException e) {
41 | throw new SettingsException(e);
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/validator/BooleanValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.validator;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsManager;
4 | import net.mslivo.pixelui.utils.settings.ValueValidator;
5 |
6 | public class BooleanValueValidator implements ValueValidator {
7 | @Override
8 | public boolean isValueValid(String value) {
9 | return SettingsManager.isValidBoolean(value);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/validator/DecimalValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.validator;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsManager;
4 | import net.mslivo.pixelui.utils.settings.ValueValidator;
5 |
6 | public class DecimalValueValidator implements ValueValidator {
7 |
8 | public final float rangeFrom, rangeTo;
9 |
10 | public DecimalValueValidator() {
11 | this(Float.MIN_VALUE, Float.MAX_VALUE);
12 | }
13 |
14 | public DecimalValueValidator(float rangeFrom, float rangeTo) {
15 | this.rangeFrom = rangeFrom;
16 | this.rangeTo = Math.max(rangeTo, rangeFrom);
17 | }
18 |
19 | @Override
20 | public boolean isValueValid(String value) {
21 | if (!SettingsManager.isValidDecimal(value)) return false;
22 | try {
23 | float v = Float.parseFloat(value);
24 | return v >= rangeFrom && v <= rangeTo;
25 | } catch (Exception e) {
26 | return false;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/validator/EnumValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.validator;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsManager;
4 | import net.mslivo.pixelui.utils.settings.ValueValidator;
5 |
6 | import java.util.HashSet;
7 |
8 | public class EnumValueValidator implements ValueValidator {
9 | private final Class c;
10 | private final HashSet allowedValuesSet;
11 |
12 | public EnumValueValidator(Class enumClass) {
13 | this(enumClass, null);
14 | }
15 |
16 | public EnumValueValidator(Class enumClass, Enum[] allowedValues) {
17 | this.c = enumClass;
18 | this.allowedValuesSet = new HashSet<>();
19 | if (allowedValues != null) {
20 | for (int i = 0; i < allowedValues.length; i++) {
21 | if (allowedValues[i] != null) allowedValuesSet.add(allowedValues[i]);
22 | }
23 | }
24 | }
25 |
26 | @Override
27 | public boolean isValueValid(String value) {
28 | if (!SettingsManager.isValidEnum(value, c)) return false;
29 | if (!this.allowedValuesSet.isEmpty() && !this.allowedValuesSet.contains(Enum.valueOf(c, value))) return false;
30 | return true;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/validator/NumberValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.validator;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsManager;
4 | import net.mslivo.pixelui.utils.settings.ValueValidator;
5 |
6 | public class NumberValueValidator implements ValueValidator {
7 |
8 | public final int rangeFrom, rangeTo;
9 |
10 | public NumberValueValidator() {
11 | this(Integer.MIN_VALUE, Integer.MAX_VALUE);
12 | }
13 |
14 | public NumberValueValidator(int rangeFrom, int rangeTo) {
15 | this.rangeFrom = rangeFrom;
16 | this.rangeTo = Math.max(rangeTo, rangeFrom);
17 | }
18 |
19 | @Override
20 | public boolean isValueValid(String value) {
21 | if (!SettingsManager.isValidNumber(value)) return false;
22 | try {
23 | int v = Integer.parseInt(value);
24 | return v >= rangeFrom && v <= rangeTo;
25 | } catch (Exception e) {
26 | return false;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/validator/StringListValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.validator;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsManager;
4 | import net.mslivo.pixelui.utils.settings.ValueValidator;
5 |
6 | import java.util.HashSet;
7 |
8 | public class StringListValueValidator implements ValueValidator {
9 | private final HashSet allowedValuesSet;
10 |
11 | public final int listSizeMin, listSizeMax;
12 |
13 | public final int listEntryLengthMin, listEntryLengthMax;
14 |
15 |
16 | public StringListValueValidator() {
17 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
18 | }
19 |
20 | public StringListValueValidator(String[] allowedValues) {
21 | this(allowedValues, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
22 | }
23 |
24 | public StringListValueValidator(String[] allowedValues, int listSizeMin, int listSizeMax) {
25 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
26 | }
27 |
28 | public StringListValueValidator(int listSizeMin, int listSizeMax) {
29 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
30 | }
31 |
32 | public StringListValueValidator(int listSizeMin, int listSizeMax, int listEntryLengthMin, int listEntryLengthMax) {
33 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
34 | }
35 |
36 | public StringListValueValidator(String[] allowedValues, int listSizeMin, int listSizeMax, int listEntryLengthMin, int listEntryLengthMax) {
37 | this.listSizeMin = listSizeMin;
38 | this.listSizeMax = listSizeMax;
39 | this.listEntryLengthMin = listEntryLengthMin;
40 | this.listEntryLengthMax = listEntryLengthMax;
41 | this.allowedValuesSet = new HashSet<>();
42 | if (allowedValues != null) {
43 | for (int i = 0; i < allowedValues.length; i++) {
44 | if (allowedValues[i] != null) allowedValuesSet.add(allowedValues[i]);
45 | }
46 | }
47 | }
48 |
49 | @Override
50 | public boolean isValueValid(String value) {
51 | if (value == null) return false;
52 | String[] stringList = value.split(SettingsManager.STRING_LIST_DELIMITER);
53 | if (stringList.length < listSizeMin || stringList.length > listSizeMax) return false;
54 | for (int i = 0; i < stringList.length; i++) {
55 | if (!SettingsManager.isValidString(stringList[i])) return false;
56 | if (!this.allowedValuesSet.isEmpty() && !this.allowedValuesSet.contains(stringList[i])) return false;
57 | if (value.length() < listEntryLengthMin || value.length() > listEntryLengthMax) return false;
58 | }
59 | return true;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/settings/validator/StringValueValidator.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.settings.validator;
2 |
3 | import net.mslivo.pixelui.utils.settings.SettingsManager;
4 | import net.mslivo.pixelui.utils.settings.ValueValidator;
5 |
6 | import java.util.HashSet;
7 |
8 | public class StringValueValidator implements ValueValidator {
9 |
10 | private final HashSet allowedValuesSet;
11 |
12 | private final int lengthMin, lengthMax;
13 |
14 | public StringValueValidator() {
15 | this(null, Integer.MIN_VALUE, Integer.MAX_VALUE);
16 | }
17 |
18 | public StringValueValidator(String[] allowedValues) {
19 | this(allowedValues, Integer.MIN_VALUE, Integer.MAX_VALUE);
20 | }
21 |
22 | public StringValueValidator(int lengthMin, int lengthMax) {
23 | this(null, Integer.MIN_VALUE, Integer.MAX_VALUE);
24 | }
25 |
26 | public StringValueValidator(String[] allowedValues, int lengthMin, int lengthMax) {
27 | this.lengthMin = lengthMin;
28 | this.lengthMax = lengthMax;
29 | this.allowedValuesSet = new HashSet<>();
30 | if(allowedValues != null){
31 | for(int i=0;i= lengthMin && value.length() <= lengthMax;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/TRANSITION_RENDER_MODE.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions;
2 |
3 | public enum TRANSITION_RENDER_MODE {
4 | FROM_FIRST,TO_FIRST
5 | }
6 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/TRANSITION_SPEED.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions;
2 |
3 | public enum TRANSITION_SPEED {
4 | IMMEDIATE(0f),
5 | VERY_SLOW(0.25f),
6 | SLOW(0.5f),
7 | DEFAULT(1.0f),
8 | FAST(2.0f),
9 | VERY_FAST(3.0f),
10 | FASTEST(4.0f);
11 |
12 | public final float value;
13 |
14 | TRANSITION_SPEED(float value) {
15 | this.value = value;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/Transition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions;
2 |
3 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
4 | import net.mslivo.pixelui.rendering.SpriteRenderer;
5 |
6 | public abstract class Transition {
7 |
8 | public final TRANSITION_SPEED transitionSpeed;
9 |
10 | public Transition() {
11 | this.transitionSpeed = TRANSITION_SPEED.DEFAULT;
12 | }
13 |
14 | public Transition(TRANSITION_SPEED transitionSpeed) {
15 | if(transitionSpeed == null)
16 | transitionSpeed = TRANSITION_SPEED.DEFAULT;
17 | this.transitionSpeed = transitionSpeed;
18 | }
19 |
20 | public abstract TRANSITION_RENDER_MODE getRenderMode();
21 |
22 | public abstract void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight);
23 |
24 | public abstract boolean update();
25 |
26 | public abstract void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from);
27 |
28 | public abstract void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to);
29 |
30 | public abstract void finished(SpriteRenderer spriteRenderer);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/FadeTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
4 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
5 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
6 | import net.mslivo.pixelui.utils.transitions.Transition;
7 | import net.mslivo.pixelui.rendering.SpriteRenderer;
8 |
9 | public class FadeTransition extends Transition {
10 | private float fadeOut;
11 | private float fadeIn;
12 |
13 | public FadeTransition(){
14 | super();
15 | }
16 |
17 | public FadeTransition(TRANSITION_SPEED transitionSpeed){
18 | super(transitionSpeed);
19 | }
20 |
21 | @Override
22 | public TRANSITION_RENDER_MODE getRenderMode() {
23 | return TRANSITION_RENDER_MODE.FROM_FIRST;
24 | }
25 |
26 | @Override
27 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
28 | this.fadeOut = 0f;
29 | this.fadeIn = 0f;
30 | }
31 |
32 | @Override
33 | public boolean update() {
34 | if(this.fadeOut < 1f){
35 | this.fadeOut = Math.min(fadeOut+0.05f,1f);
36 | return false;
37 | }else if(this.fadeIn < 1f){
38 | this.fadeIn = Math.min(fadeIn+0.05f,1f);
39 | return false;
40 | }else{
41 | return true;
42 | }
43 | }
44 |
45 | @Override
46 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
47 | if(this.fadeOut < 1f){
48 | float color = Math.clamp(0.5f-(fadeOut*0.5f),0f,1f);
49 | spriteRenderer.setTweak(color,0.5f,0.5f,0.0f);
50 | spriteRenderer.setColor(color,color,color,1f);
51 | spriteRenderer.draw(texture_from, 0, 0);
52 | spriteRenderer.setAllReset();
53 | }
54 | }
55 |
56 | @Override
57 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
58 | if(this.fadeOut >= 1 && this.fadeIn <= 1f){
59 | float color = Math.clamp(fadeIn*0.5f,0f,1f);
60 | spriteRenderer.setTweak(color,0.5f,0.5f,0.0f);
61 | spriteRenderer.setColor(color,color,color,1f);
62 | spriteRenderer.draw(texture_to, 0, 0);
63 | spriteRenderer.setAllReset();
64 | }
65 |
66 | }
67 |
68 |
69 | @Override
70 | public void finished(SpriteRenderer spriteRenderer) {
71 |
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/FallInTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
5 | import com.badlogic.gdx.math.MathUtils;
6 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
7 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
8 | import net.mslivo.pixelui.utils.transitions.Transition;
9 | import net.mslivo.pixelui.rendering.SpriteRenderer;
10 |
11 | public class FallInTransition extends Transition {
12 | private float yTo;
13 | private float ySpeed;
14 | private int bounce;
15 | private int screenHeight;
16 | private Runnable bounceAction;
17 |
18 | public FallInTransition(){
19 | this(null, null);
20 | }
21 |
22 | public FallInTransition(TRANSITION_SPEED transitionSpeed){
23 | this(null, transitionSpeed);
24 | }
25 | public FallInTransition(Runnable bounceAction, TRANSITION_SPEED transitionSpeed) {
26 | super(transitionSpeed);
27 | this.bounceAction = bounceAction;
28 | }
29 |
30 | @Override
31 | public TRANSITION_RENDER_MODE getRenderMode() {
32 | return TRANSITION_RENDER_MODE.FROM_FIRST;
33 | }
34 |
35 |
36 | @Override
37 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
38 | this.yTo = screenHeight;
39 | this.ySpeed = 0f;
40 | this.screenHeight = screenHeight;
41 | this.bounce = 5;
42 | }
43 |
44 | @Override
45 | public boolean update() {
46 |
47 | ySpeed -= screenHeight/1400f;
48 | yTo += ySpeed;
49 | if (yTo <= 0) {
50 | yTo = 0;
51 | ySpeed = -ySpeed / 2f;
52 | yTo += ySpeed;
53 | bounce--;
54 | if(bounceAction != null) bounceAction.run();
55 | }
56 | return bounce <= 0;
57 | }
58 |
59 | @Override
60 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
61 | spriteRenderer.setColor(Color.GRAY);
62 | spriteRenderer.draw(texture_from, 0, 0);
63 | }
64 |
65 | @Override
66 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
67 | spriteRenderer.setColor(Color.GRAY);
68 | spriteRenderer.draw(texture_to, 0, MathUtils.round(yTo));
69 | }
70 |
71 | @Override
72 | public void finished(SpriteRenderer spriteRenderer) {
73 |
74 | }
75 |
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/FallOutTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
5 | import com.badlogic.gdx.math.MathUtils;
6 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
7 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
8 | import net.mslivo.pixelui.utils.transitions.Transition;
9 | import net.mslivo.pixelui.rendering.SpriteRenderer;
10 |
11 | public class FallOutTransition extends Transition {
12 | private float yTo;
13 | private float ySpeed;
14 | private int screenHeight;
15 |
16 | public FallOutTransition() {
17 | super();
18 | }
19 |
20 | public FallOutTransition(TRANSITION_SPEED transitionSpeed) {
21 | super(transitionSpeed);
22 | }
23 |
24 | @Override
25 | public TRANSITION_RENDER_MODE getRenderMode() {
26 | return TRANSITION_RENDER_MODE.TO_FIRST;
27 | }
28 |
29 | @Override
30 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
31 | this.yTo = 0;
32 | this.screenHeight = screenHeight;
33 | this.ySpeed = MathUtils.round(this.screenHeight /80f);
34 | }
35 |
36 | @Override
37 | public boolean update() {
38 | ySpeed -= screenHeight /1400f;
39 | yTo += ySpeed;
40 | return yTo <= -screenHeight;
41 | }
42 |
43 | @Override
44 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
45 | spriteRenderer.setColor(Color.GRAY);
46 | spriteRenderer.draw(texture_from, 0, MathUtils.round(yTo));
47 | }
48 |
49 | @Override
50 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
51 | spriteRenderer.setColor(Color.GRAY);
52 | spriteRenderer.draw(texture_to, 0, 0);
53 | }
54 |
55 | @Override
56 | public void finished(SpriteRenderer spriteRenderer) {
57 |
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/ImmediateTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
4 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
5 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
6 | import net.mslivo.pixelui.utils.transitions.Transition;
7 | import net.mslivo.pixelui.rendering.SpriteRenderer;
8 |
9 | public class ImmediateTransition extends Transition {
10 |
11 | public ImmediateTransition(){
12 | super(TRANSITION_SPEED.IMMEDIATE);
13 | }
14 |
15 | @Override
16 | public TRANSITION_RENDER_MODE getRenderMode() {
17 | return TRANSITION_RENDER_MODE.FROM_FIRST;
18 | }
19 |
20 | @Override
21 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
22 |
23 | }
24 |
25 | @Override
26 | public boolean update() {
27 | return true;
28 | }
29 |
30 | @Override
31 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
32 | }
33 |
34 | @Override
35 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
36 | }
37 |
38 | @Override
39 | public void finished(SpriteRenderer spriteRenderer) {
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/PixelateTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
4 | import com.badlogic.gdx.graphics.glutils.ShaderProgram;
5 | import net.mslivo.pixelui.utils.Tools;
6 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
7 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
8 | import net.mslivo.pixelui.utils.transitions.Transition;
9 | import net.mslivo.pixelui.rendering.ShaderParser;
10 | import net.mslivo.pixelui.rendering.SpriteRenderer;
11 |
12 | public class PixelateTransition extends Transition {
13 | private float fadeOut;
14 | private float fadeIn;
15 |
16 | public PixelateTransition() {
17 | super();
18 | }
19 |
20 | public PixelateTransition(TRANSITION_SPEED transitionSpeed) {
21 | super(transitionSpeed);
22 | }
23 |
24 | @Override
25 | public TRANSITION_RENDER_MODE getRenderMode() {
26 | return TRANSITION_RENDER_MODE.FROM_FIRST;
27 | }
28 |
29 | private ShaderProgram pixelationShader = ShaderParser.parse(Tools.File.findResource("shaders/pixelui/pixelation.sprite.glsl"));
30 |
31 | @Override
32 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
33 | this.fadeOut = 0f;
34 | this.fadeIn = 0f;
35 | spriteRenderer.setShader(pixelationShader);
36 | }
37 |
38 | @Override
39 | public boolean update() {
40 | if (this.fadeOut < 1f) {
41 | this.fadeOut = Math.min(fadeOut + 0.02f, 1f);
42 | return false;
43 | } else if (this.fadeIn < 1f) {
44 | this.fadeIn = Math.min(fadeIn + 0.02f, 1f);
45 | return false;
46 | } else {
47 | return true;
48 | }
49 | }
50 |
51 | @Override
52 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
53 | if (this.fadeOut < 1f) {
54 | spriteRenderer.setTweak(fadeOut,0f,0f,0f);
55 | spriteRenderer.draw(texture_from, 0, 0);
56 | spriteRenderer.setAllReset();
57 | }
58 | }
59 |
60 | @Override
61 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
62 | if (this.fadeOut >= 1 && this.fadeIn <= 1f) {
63 | float color = Math.clamp(fadeIn * 0.5f, 0f, 1f);
64 | spriteRenderer.setTweak(1f-fadeIn,0f,0f,0f);
65 | spriteRenderer.draw(texture_to, 0, 0);
66 | spriteRenderer.setAllReset();
67 | }
68 |
69 | }
70 |
71 | @Override
72 | public void finished(SpriteRenderer spriteRenderer) {
73 | spriteRenderer.setShader(null);
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/ZoomInTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
5 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
6 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
7 | import net.mslivo.pixelui.utils.transitions.Transition;
8 | import net.mslivo.pixelui.rendering.SpriteRenderer;
9 |
10 | public class ZoomInTransition extends Transition {
11 | private float zoom, zoomAcc;
12 | private int screenWidth;
13 | private int screenHeight;
14 |
15 | public ZoomInTransition() {
16 | super();
17 | }
18 |
19 | public ZoomInTransition(TRANSITION_SPEED transitionSpeed) {
20 | super(transitionSpeed);
21 | }
22 |
23 | @Override
24 | public TRANSITION_RENDER_MODE getRenderMode() {
25 | return TRANSITION_RENDER_MODE.TO_FIRST;
26 | }
27 |
28 | @Override
29 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
30 | this.screenWidth = screenWidth;
31 | this.screenHeight = screenHeight;
32 | this.zoom = 0f;
33 | this.zoomAcc = 0.02f;
34 | }
35 |
36 | @Override
37 | public boolean update() {
38 | this.zoom += zoomAcc;
39 | return this.zoom > 1f;
40 | }
41 |
42 | @Override
43 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
44 | spriteRenderer.setColor(0.5f,0.5f,0.5f,1f-zoom);
45 | spriteRenderer.draw(texture_from, -screenWidth*(zoom/2f),-screenHeight*(zoom/2f),screenWidth*(zoom+1), screenHeight*(zoom+1));
46 | spriteRenderer.setColor(Color.GRAY);
47 | }
48 |
49 | @Override
50 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
51 | spriteRenderer.draw(texture_to, 0, 0);
52 | }
53 |
54 | @Override
55 | public void finished(SpriteRenderer spriteRenderer) {
56 |
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/core/src/main/java/net/mslivo/pixelui/utils/transitions/basic/ZoomOutTransition.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.pixelui.utils.transitions.basic;
2 |
3 | import com.badlogic.gdx.graphics.Color;
4 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
5 | import com.badlogic.gdx.math.MathUtils;
6 | import net.mslivo.pixelui.utils.transitions.TRANSITION_RENDER_MODE;
7 | import net.mslivo.pixelui.utils.transitions.TRANSITION_SPEED;
8 | import net.mslivo.pixelui.utils.transitions.Transition;
9 | import net.mslivo.pixelui.rendering.SpriteRenderer;
10 |
11 | public class ZoomOutTransition extends Transition {
12 | private float zoom, zoomAcc;
13 | private int screenWidth;
14 | private int screenHeight;
15 |
16 | public ZoomOutTransition() {
17 | super();
18 | }
19 |
20 | public ZoomOutTransition(TRANSITION_SPEED transitionSpeed) {
21 | super(transitionSpeed);
22 | }
23 |
24 | @Override
25 | public TRANSITION_RENDER_MODE getRenderMode() {
26 | return TRANSITION_RENDER_MODE.TO_FIRST;
27 | }
28 |
29 | @Override
30 | public void init(SpriteRenderer spriteRenderer, int screenWidth, int screenHeight) {
31 | this.screenWidth = screenWidth;
32 | this.screenHeight = screenHeight;
33 | this.zoom = 1f;
34 | this.zoomAcc = 0.02f;
35 | }
36 |
37 | @Override
38 | public boolean update() {
39 | this.zoom -= zoomAcc;
40 | return this.zoom < 0f;
41 | }
42 |
43 | @Override
44 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) {
45 | if(zoom > 0f) {
46 | spriteRenderer.draw(texture_from,
47 | MathUtils.round(screenWidth * (1f - zoom) * 0.5f),
48 | MathUtils.round(screenHeight * (1f - zoom) * 0.5f),
49 | MathUtils.round(screenWidth * zoom),
50 | MathUtils.round(screenHeight * zoom));
51 | }
52 | }
53 |
54 | @Override
55 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) {
56 | spriteRenderer.setColor(Color.GRAY);
57 | spriteRenderer.draw(texture_to, 0, 0);
58 | }
59 |
60 | @Override
61 | public void finished(SpriteRenderer spriteRenderer) {
62 |
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/background.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_animation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_animation.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_animation_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_animation_2.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_array.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_array.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_bullet_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_bullet_blue.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_bullet_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_bullet_green.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_bullet_orange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_bullet_orange.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_cursor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_cursor.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_icon_1.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_icon_2.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_icon_3.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_icon_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_icon_4.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_icon_double.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_icon_double.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/example_icon_window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/example_icon_window.png
--------------------------------------------------------------------------------
/desktop/assets_example/sprites/example/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/desktop/assets_example/sprites/example/test.png
--------------------------------------------------------------------------------
/desktop/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | net.mslivo
7 | pixeluiengine
8 | 1.0
9 |
10 | pixeluiengine-desktop
11 | jar
12 |
13 |
14 |
15 |
16 | net.mslivo
17 | pixeluiengine-core
18 | 1.0
19 |
20 |
21 |
22 |
23 |
24 |
25 | ../assets
26 |
27 |
28 | assets_example
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-compiler-plugin
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-assembly-plugin
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/desktop/src/main/java/net/mslivo/example/ExampleLauncherMain.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.example;
2 |
3 |
4 | import net.mslivo.pixelui.utils.PixelUILaunchConfig;
5 | import net.mslivo.pixelui.utils.Tools;
6 |
7 | public class ExampleLauncherMain {
8 |
9 | public static void main(String[] args) {
10 |
11 |
12 | PixelUILaunchConfig pixelUILaunchConfig = new PixelUILaunchConfig();
13 | pixelUILaunchConfig.appTile = ExampleMainConstants.APP_TITLE;
14 | pixelUILaunchConfig.resolutionWidth = ExampleMainConstants.INTERNAL_RESOLUTION_WIDTH;
15 | pixelUILaunchConfig.resolutionHeight = ExampleMainConstants.INTERNAL_RESOLUTION_HEIGHT;
16 |
17 | Tools.App.launch(new ExampleMain(), pixelUILaunchConfig);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/desktop/src/main/java/net/mslivo/example/ExampleMain.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.example;
2 |
3 | import com.badlogic.gdx.ApplicationAdapter;
4 | import net.mslivo.pixelui.media.MediaManager;
5 | import net.mslivo.pixelui.utils.Tools;
6 | import net.mslivo.pixelui.utils.transitions.TransitionManager;
7 | import net.mslivo.pixelui.utils.transitions.basic.PixelateTransition;
8 | import net.mslivo.pixelui.engine.UIEngine;
9 | import net.mslivo.example.ui.ExampleUIEngineAdapter;
10 | import net.mslivo.example.ui.media.ExampleBaseMedia;
11 |
12 | public class ExampleMain extends ApplicationAdapter {
13 | enum STATE {
14 | RUN, TRANSITION
15 | }
16 |
17 | private STATE state;
18 | private TransitionManager transitionManager;
19 | private MediaManager mediaManager;
20 | private UIEngine uiEngine;
21 | private UIEngine uiEngine_transition;
22 | private long timer_debug_info;
23 |
24 | public ExampleMain() {
25 | }
26 |
27 | @Override
28 | public void resize(int width, int height) {
29 | if (this.uiEngine != null) this.uiEngine.resize(width, height);
30 | }
31 |
32 |
33 | @Override
34 | public void create() {
35 | Tools.App.setTargetUpdates(ExampleMainConstants.UPDATE_RATE);
36 | this.transitionManager = null;
37 | // Load Assets
38 | System.out.println("Loading Assets");
39 | this.mediaManager = new MediaManager();
40 | this.mediaManager.prepareUIEngineBaseCMedia();
41 | this.mediaManager.prepareCMedia(ExampleBaseMedia.ALL);
42 | this.mediaManager.loadAssets();
43 | System.out.println("Done.");
44 |
45 | // Input/Render
46 | System.out.println("Starting UI");
47 | this.uiEngine = new UIEngine<>(
48 | new ExampleUIEngineAdapter(),
49 | this.mediaManager, ExampleMainConstants.INTERNAL_RESOLUTION_WIDTH, ExampleMainConstants.INTERNAL_RESOLUTION_HEIGHT,
50 | ExampleMainConstants.viewportMode, true);
51 | System.out.println("Done.");
52 |
53 | this.state = STATE.RUN;
54 |
55 | }
56 |
57 |
58 | @Override
59 | public void render() {
60 | switch (state) {
61 |
62 | case RUN -> {
63 | if (Tools.App.runUpdate()) {
64 | this.uiEngine.update();
65 | }
66 |
67 | this.uiEngine.render();
68 | // Check for transition + Reset
69 | if (this.uiEngine.getAdapter().isResetPressed()) {
70 | this.uiEngine_transition = new UIEngine<>(
71 | new ExampleUIEngineAdapter(),
72 | this.mediaManager, ExampleMainConstants.INTERNAL_RESOLUTION_WIDTH, ExampleMainConstants.INTERNAL_RESOLUTION_HEIGHT,
73 | ExampleMainConstants.viewportMode);
74 | this.uiEngine_transition.update();
75 | this.transitionManager = new TransitionManager(this.uiEngine, this.uiEngine_transition, new PixelateTransition());
76 | this.transitionManager.render();
77 | state = STATE.TRANSITION;
78 | return;
79 | }
80 |
81 | }
82 | case TRANSITION -> {
83 | if (Tools.App.runUpdate()) {
84 | boolean finished = this.transitionManager.update();
85 | if (finished) {
86 | // Replace with new UIEngine after Reset
87 | this.uiEngine.dispose();
88 | this.uiEngine = this.uiEngine_transition;
89 | this.uiEngine_transition = null;
90 | this.state = STATE.RUN;
91 | return;
92 | }
93 | }
94 | transitionManager.render();
95 | }
96 | }
97 |
98 | // Debug Output
99 | if (System.currentTimeMillis() - timer_debug_info > 1000) {
100 | System.out.println(Tools.Text.benchmark());
101 | timer_debug_info = System.currentTimeMillis();
102 | }
103 |
104 |
105 | }
106 |
107 | @Override
108 | public void dispose() {
109 | System.out.println("Shutting down...");
110 | this.shutdownEngine();
111 | System.out.println("Done.");
112 | }
113 |
114 | private void shutdownEngine() {
115 | this.uiEngine.dispose();
116 | this.mediaManager.dispose();
117 | }
118 |
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/desktop/src/main/java/net/mslivo/example/ExampleMainConstants.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.example;
2 |
3 |
4 | import net.mslivo.pixelui.engine.constants.VIEWPORT_MODE;
5 |
6 | public class ExampleMainConstants {
7 |
8 | private ExampleMainConstants() {
9 | }
10 |
11 | public static final String APP_TITLE = "Engine Example";
12 | public static final int UPDATE_RATE = 60;
13 | public static final int INTERNAL_RESOLUTION_WIDTH = 640;
14 | public static final int INTERNAL_RESOLUTION_HEIGHT = 480;
15 | public static final VIEWPORT_MODE viewportMode = VIEWPORT_MODE.PIXEL_PERFECT;
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/desktop/src/main/java/net/mslivo/example/ui/media/ExampleBaseMedia.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.example.ui.media;
2 |
3 | import net.mslivo.pixelui.media.*;
4 |
5 | public class ExampleBaseMedia {
6 | private static final String DIR_EXAMPLE_GRAPHICS = MediaManager.DIR_GRAPHICS + "example/";
7 | public static final CMediaArray BUTTON_ANIM_EXAMPLE_ARRAY = new CMediaArray(DIR_EXAMPLE_GRAPHICS + "example_array.png", 16, 8);
8 | public static final CMediaImage ICON_EXAMPLE_1 = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_icon_1.png");
9 | public static final CMediaImage ICON_EXAMPLE_2 = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_icon_2.png");
10 | public static final CMediaImage ICON_EXAMPLE_3 = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_icon_3.png");
11 | public static final CMediaImage ICON_EXAMPLE_4 = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_icon_4.png");
12 | public static final CMediaImage ICON_EXAMPLE_DOUBLE = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_icon_double.png");
13 | public static final CMediaImage ICON_EXAMPLE_BULLET_GREEN = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_bullet_green.png");
14 | public static final CMediaImage ICON_EXAMPLE_BULLET_BLUE = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_bullet_blue.png");
15 | public static final CMediaImage ICON_EXAMPLE_BULLET_ORANGE = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_bullet_orange.png");
16 | public static final CMediaImage ICON_EXAMPLE_WINDOW = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "example_icon_window.png");
17 | public static final CMediaAnimation EXAMPLE_ANIMATION_2 = new CMediaAnimation(DIR_EXAMPLE_GRAPHICS + "example_animation_2.png", 8*8, 8*8, 0.1f);
18 | public static final CMediaAnimation EXAMPLE_ANIMATION_3 = new CMediaAnimation(DIR_EXAMPLE_GRAPHICS + "example_animation_2.png", 8*8, 8*8, 0.01f);
19 | public static final CMediaImage EXAMPLE_TEST = new CMediaImage(DIR_EXAMPLE_GRAPHICS + "test.png", false);
20 |
21 | public static final CMediaAnimation EXAMPLE_ANIMATION = new CMediaAnimation(DIR_EXAMPLE_GRAPHICS + "example_animation.png", 16, 8, 0.1f);
22 | public static final CMediaAnimation BACKGROUND = new CMediaAnimation(DIR_EXAMPLE_GRAPHICS + "background.png", 16, 16, 0.2f);
23 | public static final CMedia[] ALL = new CMedia[]{
24 | EXAMPLE_ANIMATION,EXAMPLE_ANIMATION_3,EXAMPLE_TEST,
25 | BUTTON_ANIM_EXAMPLE_ARRAY,
26 | ICON_EXAMPLE_1,
27 | ICON_EXAMPLE_2,
28 | ICON_EXAMPLE_3,
29 | ICON_EXAMPLE_4,
30 | ICON_EXAMPLE_DOUBLE,
31 | ICON_EXAMPLE_BULLET_GREEN,
32 | ICON_EXAMPLE_BULLET_BLUE,
33 | ICON_EXAMPLE_BULLET_ORANGE,
34 | ICON_EXAMPLE_WINDOW,
35 | EXAMPLE_ANIMATION_2,
36 | BACKGROUND
37 | };
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/desktop/src/main/java/net/mslivo/example/ui/media/ParticleData.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.example.ui.media;
2 |
3 | public class ParticleData{
4 | int randomData = 0;
5 |
6 | public ParticleData() {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/desktop/src/main/java/net/mslivo/performancetest/ThreadTest.java:
--------------------------------------------------------------------------------
1 | package net.mslivo.performancetest;
2 |
3 | import com.badlogic.gdx.math.MathUtils;
4 | import com.badlogic.gdx.utils.Array;
5 | import net.mslivo.pixelui.utils.Tools;
6 |
7 | import java.util.concurrent.atomic.AtomicInteger;
8 | import java.util.function.Consumer;
9 |
10 | public class ThreadTest {
11 |
12 | private Array list = new Array<>();
13 | private long startTime;
14 | private AtomicInteger sum = new AtomicInteger();
15 | private TestConsumer testConsumer = new TestConsumer();
16 | private int expected;
17 | private String test;
18 |
19 | class TestConsumer implements Consumer {
20 |
21 | @Override
22 | public void accept(Integer value) {
23 | synchronized (sum){
24 | sum.set(sum.get()+value);
25 | }
26 | }
27 | }
28 |
29 | public static void main(String[]args){
30 | ThreadTest threadTest = new ThreadTest();
31 |
32 |
33 | for(int i=0;i<10;i++) {
34 | threadTest.start("parallelRunner.run()");
35 | threadTest.runTestParallelRunner();
36 | threadTest.end();
37 |
38 | }
39 |
40 | System.out.println(String.format("%1$6s", ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)))+"MB");
41 | }
42 |
43 | public void start(String test){
44 | final int COUNT = 10_000_000;
45 | this.test = test;
46 | this.sum.set(0);
47 | this.expected = 0;
48 | this.list.clear();
49 | for(int i=0;i
2 |
4 | 4.0.0
5 | net.mslivo
6 | pixeluiengine
7 | 1.0
8 | pom
9 |
10 | 24
11 | 1.13.5
12 | 2.2.3
13 | net.mslivo.example.ExampleLauncherMain
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | com.badlogicgames.gdx
22 | gdx
23 | ${gdx.version}
24 | compile
25 |
26 |
27 | com.badlogicgames.gdx
28 | gdx-backend-lwjgl3
29 | ${gdx.version}
30 | compile
31 |
32 |
33 | com.badlogicgames.gdx
34 | gdx-platform
35 | ${gdx.version}
36 | natives-desktop
37 | compile
38 |
39 |
40 |
41 |
42 |
43 | com.badlogicgames.gdx-controllers
44 | gdx-controllers-core
45 | ${gdx-controllers.version}
46 | compile
47 |
48 |
49 | com.badlogicgames.gdx-controllers
50 | gdx-controllers-desktop
51 | ${gdx-controllers.version}
52 | compile
53 |
54 |
55 |
56 |
57 |
58 |
59 | com.github.Dgzt
60 | gdx-lwjgl3-angle-vulkan
61 | 1.3.0
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | gdx-nightlies
71 | https://oss.sonatype.org/content/repositories/snapshots/
72 |
73 |
74 | gdx-releases
75 | https://oss.sonatype.org/content/repositories/releases/
76 |
77 |
78 | jitpack.io
79 | https://jitpack.io
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | org.apache.maven.plugins
88 | maven-compiler-plugin
89 | 3.11.0
90 |
91 | ${java.version}
92 | ${java.version}
93 |
94 |
95 |
96 | org.apache.maven.plugins
97 | maven-jar-plugin
98 | 3.3.0
99 |
100 |
101 | org.apache.maven.plugins
102 | maven-assembly-plugin
103 | 3.3.0
104 |
105 |
106 | jar-with-dependencies
107 |
108 |
109 |
110 | ${mainClass}
111 |
112 |
113 |
114 |
115 |
116 | make-assembly
117 | package
118 |
119 | single
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | core
131 | desktop
132 |
133 |
134 |
--------------------------------------------------------------------------------
/screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/screenshot_1.png
--------------------------------------------------------------------------------
/screenshot_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mslivo/PixelUIEngine/745b4ebff701bf6e7e0fec038952a834d9d5f5f4/screenshot_2.png
--------------------------------------------------------------------------------