├── logo.png ├── screenshot_1.png ├── screenshot_2.png ├── assets ├── sprites │ └── pixelui │ │ ├── base8x8 │ │ ├── pixel.png │ │ ├── ui │ │ │ ├── tab.png │ │ │ ├── grid.png │ │ │ ├── knob.png │ │ │ ├── list.png │ │ │ ├── radio.png │ │ │ ├── border.png │ │ │ ├── button.png │ │ │ ├── checkbox.png │ │ │ ├── combobox.png │ │ │ ├── grid_x2.png │ │ │ ├── tooltip.png │ │ │ ├── window.png │ │ │ ├── grid_cell.png │ │ │ ├── list_cell.png │ │ │ ├── list_drag.png │ │ │ ├── radio_cell.png │ │ │ ├── tab_border.png │ │ │ ├── textfield.png │ │ │ ├── checkbox_cell.png │ │ │ ├── combobox_cell.png │ │ │ ├── combobox_list.png │ │ │ ├── combobox_open.png │ │ │ ├── combobox_top.png │ │ │ ├── context_menu.png │ │ │ ├── grid_cell_x2.png │ │ │ ├── grid_dragged.png │ │ │ ├── knob_endless.png │ │ │ ├── progressbar.png │ │ │ ├── tab_bigicon.png │ │ │ ├── tab_selected.png │ │ │ ├── tooltip_cell.png │ │ │ ├── tooltip_top.png │ │ │ ├── button_pressed.png │ │ │ ├── grid_dragged_x2.png │ │ │ ├── knob_background.png │ │ │ ├── progressbar_bar.png │ │ │ ├── textfield_caret.png │ │ │ ├── textfield_cell.png │ │ │ ├── combobox_list_cell.png │ │ │ ├── context_menu_cell.png │ │ │ ├── context_menu_top.png │ │ │ ├── grid_cell_selected.png │ │ │ ├── list_cell_selected.png │ │ │ ├── notification_bar.png │ │ │ ├── scrollbar_vertical.png │ │ │ ├── separator_vertical.png │ │ │ ├── mouseinput_lowercase.png │ │ │ ├── scrollbar_horizontal.png │ │ │ ├── separator_horizontal.png │ │ │ ├── grid_cell_selected_x2.png │ │ │ ├── mousetextinput_button.png │ │ │ ├── mousetextinput_confirm.png │ │ │ ├── mousetextinput_delete.png │ │ │ ├── mousetextinput_selected.png │ │ │ ├── tab__bigicon_selected.png │ │ │ ├── tooltip_line_horizontal.png │ │ │ ├── tooltip_line_vertical.png │ │ │ ├── tooltip_segment_border.png │ │ │ ├── mousetextinput_lowercase.png │ │ │ ├── mousetextinput_uppercase.png │ │ │ ├── scrollbar_button_vertical.png │ │ │ ├── textfield_cell_validation.png │ │ │ ├── combobox_list_cell_selected.png │ │ │ ├── context_menu_cell_selected.png │ │ │ └── scrollbar_button_horizontal.png │ │ ├── fonts │ │ │ └── font.png │ │ ├── cursors │ │ │ └── arrow.png │ │ ├── icons │ │ │ ├── back.icon.png │ │ │ ├── close.icon.png │ │ │ ├── extend.icon.png │ │ │ ├── forward.icon.png │ │ │ ├── question.icon.png │ │ │ └── information.icon.png │ │ └── pixel_transparent.png │ │ └── misc │ │ └── font_small.png └── shaders │ └── pixelui │ ├── default.primitive.glsl │ ├── default.sprite.glsl │ ├── pixelation.sprite.glsl │ ├── blur.sprite.glsl │ ├── lut.sprite.glsl │ └── hsl.sprite.glsl ├── desktop ├── assets_example │ └── sprites │ │ └── example │ │ ├── test.png │ │ ├── background.png │ │ ├── example_array.png │ │ ├── example_cursor.png │ │ ├── example_icon_1.png │ │ ├── example_icon_2.png │ │ ├── example_icon_3.png │ │ ├── example_icon_4.png │ │ ├── example_animation.png │ │ ├── example_animation_2.png │ │ ├── example_bullet_blue.png │ │ ├── example_bullet_green.png │ │ ├── example_icon_double.png │ │ ├── example_icon_window.png │ │ └── example_bullet_orange.png ├── src │ └── main │ │ └── java │ │ └── net │ │ └── mslivo │ │ ├── example │ │ ├── ui │ │ │ └── media │ │ │ │ ├── ParticleData.java │ │ │ │ └── ExampleBaseMedia.java │ │ ├── ExampleMainConstants.java │ │ ├── ExampleLauncherMain.java │ │ └── ExampleMain.java │ │ └── performancetest │ │ └── ThreadTest.java └── pom.xml ├── core ├── src │ └── main │ │ └── java │ │ └── net │ │ └── mslivo │ │ └── pixelui │ │ ├── utils │ │ ├── helper │ │ │ ├── Copyable.java │ │ │ ├── UpdateTimer.java │ │ │ └── ValueWatcher.java │ │ ├── systems │ │ │ ├── appengine │ │ │ │ ├── AppEngineParameter.java │ │ │ │ ├── AppEngineOutputQueue.java │ │ │ │ ├── AppEngineAdapter.java │ │ │ │ └── AppEngine.java │ │ │ ├── particles │ │ │ │ ├── particles │ │ │ │ │ ├── EmptyParticle.java │ │ │ │ │ ├── ImageParticle.java │ │ │ │ │ ├── ArrayParticle.java │ │ │ │ │ ├── AnimationParticle.java │ │ │ │ │ ├── SpriteParticle.java │ │ │ │ │ ├── Particle.java │ │ │ │ │ ├── TextParticle.java │ │ │ │ │ ├── PrimitiveParticle.java │ │ │ │ │ └── TextureBasedParticle.java │ │ │ │ └── ParticleUpdater.java │ │ │ └── transitions │ │ │ │ ├── TRANSITION_RENDER_ORDER.java │ │ │ │ ├── TRANSITION_SPEED.java │ │ │ │ ├── Transition.java │ │ │ │ └── basic │ │ │ │ ├── ImmediateTransition.java │ │ │ │ ├── FallOutTransition.java │ │ │ │ ├── ZoomInTransition.java │ │ │ │ ├── ZoomOutTransition.java │ │ │ │ ├── FadeTransition.java │ │ │ │ ├── FallInTransition.java │ │ │ │ └── PixelateTransition.java │ │ ├── persistence │ │ │ ├── settings │ │ │ │ ├── ValueValidator.java │ │ │ │ ├── SettingsPersistor.java │ │ │ │ ├── validator │ │ │ │ │ ├── BooleanValueValidator.java │ │ │ │ │ ├── DecimalValueValidator.java │ │ │ │ │ ├── NumberValueValidator.java │ │ │ │ │ ├── EnumValueValidator.java │ │ │ │ │ ├── StringValueValidator.java │ │ │ │ │ └── StringListValueValidator.java │ │ │ │ └── persistor │ │ │ │ │ └── PropertiesFilePersistor.java │ │ │ └── highscore │ │ │ │ └── SaveScoreResult.java │ │ └── PixelUILaunchConfig.java │ │ ├── engine │ │ ├── ScrollbarVertical.java │ │ ├── ScrollbarHorizontal.java │ │ ├── actions │ │ │ ├── HotKeyAction.java │ │ │ ├── ShapeAction.java │ │ │ ├── ImageAction.java │ │ │ ├── ProgressBarAction.java │ │ │ ├── common │ │ │ │ ├── Displayable.java │ │ │ │ ├── UpdateActionSupport.java │ │ │ │ ├── CellColor.java │ │ │ │ ├── ItemCellColor.java │ │ │ │ ├── CommonActions.java │ │ │ │ ├── Icon.java │ │ │ │ ├── ItemIcons.java │ │ │ │ └── UpdateAction.java │ │ │ ├── TabAction.java │ │ │ ├── TextAction.java │ │ │ ├── ToolTipAction.java │ │ │ ├── CheckboxAction.java │ │ │ ├── NotificationAction.java │ │ │ ├── TabBarAction.java │ │ │ ├── ComboBoxItemAction.java │ │ │ ├── ContextMenuItemAction.java │ │ │ ├── AppViewPortAction.java │ │ │ ├── FrameBufferViewportAction.java │ │ │ ├── KnobAction.java │ │ │ ├── ScrollBarAction.java │ │ │ ├── ContextMenuAction.java │ │ │ ├── ButtonAction.java │ │ │ ├── MouseTextInputAction.java │ │ │ ├── ComboBoxAction.java │ │ │ ├── WindowAction.java │ │ │ ├── TextFieldAction.java │ │ │ ├── GridAction.java │ │ │ └── ListAction.java │ │ ├── TooltipTextSegment.java │ │ ├── TextButton.java │ │ ├── ImageButton.java │ │ ├── TooltipFramebufferViewportSegment.java │ │ ├── constants │ │ │ ├── BUTTON_MODE.java │ │ │ ├── CHECKBOX_STYLE.java │ │ │ ├── SEGMENT_ALIGNMENT.java │ │ │ ├── INPUT_METHOD.java │ │ │ ├── SHAPE_ROTATION.java │ │ │ ├── TOOLTIP_NOTIFICATION_STATE.java │ │ │ ├── SHAPE_TYPE.java │ │ │ ├── VIEWPORT_MODE.java │ │ │ ├── TOP_NOTIFICATION_STATE.java │ │ │ ├── MOUSE_CONTROL_MODE.java │ │ │ ├── TileSize.java │ │ │ ├── DIRECTION.java │ │ │ └── DIRECTION8.java │ │ ├── Knob.java │ │ ├── TooltipNotification.java │ │ ├── Text.java │ │ ├── HotKey.java │ │ ├── TooltipImageSegment.java │ │ ├── MouseTool.java │ │ ├── GenericNotification.java │ │ ├── TooltipImage.java │ │ ├── ComboBox.java │ │ ├── Scrollbar.java │ │ ├── Image.java │ │ ├── ContextMenu.java │ │ ├── ComboBoxItem.java │ │ ├── Progressbar.java │ │ ├── FrameBufferViewport.java │ │ ├── ContextMenuItem.java │ │ ├── Tabbar.java │ │ ├── Checkbox.java │ │ ├── Button.java │ │ ├── Tab.java │ │ ├── Grid.java │ │ ├── AppViewport.java │ │ ├── Notification.java │ │ ├── TooltipSegment.java │ │ ├── MouseTextInput.java │ │ ├── TextField.java │ │ ├── List.java │ │ ├── Tooltip.java │ │ ├── Component.java │ │ ├── WindowGenerator.java │ │ ├── Window.java │ │ ├── UIEngineAdapter.java │ │ ├── APIMouseTool.java │ │ ├── APIHotkey.java │ │ ├── UIInputEvents.java │ │ ├── APICamera.java │ │ └── APINotification.java │ │ ├── media │ │ ├── LoadProgress.java │ │ ├── CMediaMusic.java │ │ ├── CMediaSoundEffect.java │ │ ├── OUTLINE.java │ │ ├── CMediaImage.java │ │ ├── CMediaSound.java │ │ ├── CMedia.java │ │ ├── CMediaFontSymbolSingle.java │ │ ├── CMediaSprite.java │ │ ├── CMediaFontSymbol.java │ │ ├── CMediaFontOutline.java │ │ ├── CMediaArray.java │ │ ├── CMediaFontSymbolArray.java │ │ ├── CMediaFont.java │ │ └── CMediaAnimation.java │ │ └── rendering │ │ ├── PixelPerfectViewport.java │ │ ├── NestedFrameBuffer.java │ │ └── ExtendedAnimation.java └── pom.xml ├── .gitignore ├── README.md └── pom.xml /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/logo.png -------------------------------------------------------------------------------- /screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/screenshot_1.png -------------------------------------------------------------------------------- /screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/screenshot_2.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/pixel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/pixel.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tab.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/knob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/knob.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/list.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/radio.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/misc/font_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/misc/font_small.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/fonts/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/fonts/font.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/border.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/button.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/checkbox.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_x2.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tooltip.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/window.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/cursors/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/cursors/arrow.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/list_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/list_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/list_drag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/list_drag.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/radio_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/radio_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tab_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tab_border.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/textfield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/textfield.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/test.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/icons/back.icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/icons/back.icon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/icons/close.icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/icons/close.icon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/checkbox_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/checkbox_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox_list.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox_open.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox_top.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/context_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/context_menu.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_cell_x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_cell_x2.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_dragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_dragged.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/knob_endless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/knob_endless.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/progressbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/progressbar.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tab_bigicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tab_bigicon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tab_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tab_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tooltip_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tooltip_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tooltip_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tooltip_top.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/icons/extend.icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/icons/extend.icon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/icons/forward.icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/icons/forward.icon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/pixel_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/pixel_transparent.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/button_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/button_pressed.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_dragged_x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_dragged_x2.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/knob_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/knob_background.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/progressbar_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/progressbar_bar.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/textfield_caret.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/textfield_caret.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/textfield_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/textfield_cell.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/background.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/icons/question.icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/icons/question.icon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox_list_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox_list_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/context_menu_cell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/context_menu_cell.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/context_menu_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/context_menu_top.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_cell_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_cell_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/list_cell_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/list_cell_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/notification_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/notification_bar.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/scrollbar_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/scrollbar_vertical.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/separator_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/separator_vertical.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_array.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/icons/information.icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/icons/information.icon.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mouseinput_lowercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mouseinput_lowercase.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/scrollbar_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/scrollbar_horizontal.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/separator_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/separator_horizontal.png -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/helper/Copyable.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.helper; 2 | 3 | public interface Copyable { 4 | T copy(); 5 | } 6 | -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_cursor.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_icon_1.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_icon_2.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_icon_3.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_icon_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_icon_4.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/grid_cell_selected_x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/grid_cell_selected_x2.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mousetextinput_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mousetextinput_button.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mousetextinput_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mousetextinput_confirm.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mousetextinput_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mousetextinput_delete.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mousetextinput_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mousetextinput_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tab__bigicon_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tab__bigicon_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tooltip_line_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tooltip_line_horizontal.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tooltip_line_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tooltip_line_vertical.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/tooltip_segment_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/tooltip_segment_border.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_animation.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mousetextinput_lowercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mousetextinput_lowercase.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/mousetextinput_uppercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/mousetextinput_uppercase.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/scrollbar_button_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/scrollbar_button_vertical.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/textfield_cell_validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/textfield_cell_validation.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_animation_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_animation_2.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_bullet_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_bullet_blue.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_bullet_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_bullet_green.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_icon_double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_icon_double.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_icon_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_icon_window.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/combobox_list_cell_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/combobox_list_cell_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/context_menu_cell_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/context_menu_cell_selected.png -------------------------------------------------------------------------------- /assets/sprites/pixelui/base8x8/ui/scrollbar_button_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/assets/sprites/pixelui/base8x8/ui/scrollbar_button_horizontal.png -------------------------------------------------------------------------------- /desktop/assets_example/sprites/example/example_bullet_orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mslivo/PixelUIEngine/HEAD/desktop/assets_example/sprites/example/example_bullet_orange.png -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/appengine/AppEngineParameter.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.appengine; 2 | 3 | public abstract class AppEngineParameter { 4 | } 5 | -------------------------------------------------------------------------------- /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/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/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/utils/systems/particles/particles/EmptyParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.particles.particles; 2 | 3 | public final class EmptyParticle extends Particle{ 4 | } 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/TRANSITION_RENDER_ORDER.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.transitions; 2 | 3 | public enum TRANSITION_RENDER_ORDER { 4 | FROM_FIRST,TO_FIRST 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/particles/particles/ImageParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.particles.particles; 2 | 3 | public final class ImageParticle extends TextureBasedParticle { 4 | } 5 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/persistence/settings/ValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings; 2 | 3 | public interface ValueValidator { 4 | 5 | boolean isValueValid(String value); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /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/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/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/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/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/utils/systems/particles/particles/ArrayParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.particles.particles; 2 | 3 | public final class ArrayParticle extends TextureBasedParticle { 4 | public int arrayIndex; 5 | } 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/appengine/AppEngineOutputQueue.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/engine/actions/common/UpdateActionSupport.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine.actions.common; 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/utils/systems/particles/particles/AnimationParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/systems/particles/particles/SpriteParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.particles.particles; 2 | 3 | public abstract sealed class SpriteParticle extends Particle permits TextParticle, TextureBasedParticle { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /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/utils/persistence/highscore/SaveScoreResult.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.highscore; 2 | 3 | import java.math.BigInteger; 4 | 5 | public record SaveScoreResult(String table, String name, BigInteger score, int place, boolean isHighScore){ 6 | } -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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 | public 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/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/Knob.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | import net.mslivo.pixelui.engine.actions.KnobAction; 4 | 5 | public final 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/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 | -------------------------------------------------------------------------------- /assets/shaders/pixelui/default.primitive.glsl: -------------------------------------------------------------------------------- 1 | // Usable Vertex Shader Variables: vec4 a_position | vec4 v_vertexColor 2 | // Usable Fragment Shader Variables: vec4 v_vertexColor 3 | 4 | // BEGIN VERTEX 5 | 6 | void main(){ 7 | } 8 | 9 | // END VERTEX 10 | 11 | // BEGIN FRAGMENT 12 | 13 | void main(){ 14 | gl_FragColor = v_vertexColor; 15 | } 16 | // END FRAGMENT -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/particles/particles/Particle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/engine/TooltipNotification.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | import net.mslivo.pixelui.engine.constants.TOOLTIP_NOTIFICATION_STATE; 4 | 5 | public final 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/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/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/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/utils/persistence/settings/SettingsPersistor.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.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/systems/particles/particles/TextParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/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 final 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/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/utils/systems/appengine/AppEngineAdapter.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.appengine; 2 | 3 | public interface AppEngineAdapter { 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/systems/particles/particles/PrimitiveParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/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/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/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/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/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/MouseTool.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | import net.mslivo.pixelui.media.CMediaSprite; 4 | 5 | public final 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/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/TooltipImage.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | import net.mslivo.pixelui.media.CMediaSprite; 4 | 5 | public final 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/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/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 final 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/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/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/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/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 final 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/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/utils/systems/particles/ParticleUpdater.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.particles; 2 | 3 | 4 | import net.mslivo.pixelui.utils.systems.particles.particles.Particle; 5 | 6 | public interface ParticleUpdater { 7 | default boolean updateParticle(Particle particle){ 8 | return true; 9 | }; 10 | 11 | default void resetParticleData(T particleData){ 12 | return; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/TRANSITION_SPEED.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/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/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/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/utils/systems/particles/particles/TextureBasedParticle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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/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/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/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 final 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/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 boolean onToggle(boolean value) { 15 | return true; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /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 final 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/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/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 final 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/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/utils/persistence/settings/validator/BooleanValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.validator; 2 | 3 | 4 | import net.mslivo.pixelui.utils.persistence.settings.SettingsManager; 5 | import net.mslivo.pixelui.utils.persistence.settings.ValueValidator; 6 | 7 | public class BooleanValueValidator implements ValueValidator { 8 | @Override 9 | public boolean isValueValid(String value) { 10 | return SettingsManager.isValidBoolean(value); 11 | } 12 | } -------------------------------------------------------------------------------- /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/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 final 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/media/CMediaMusic.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import net.mslivo.pixelui.utils.helper.Copyable; 4 | 5 | public final class CMediaMusic extends CMediaSound implements Copyable { 6 | 7 | public CMediaMusic() { 8 | super(); 9 | } 10 | 11 | public CMediaMusic(String filename) { 12 | super(filename); 13 | } 14 | 15 | @Override 16 | public CMediaMusic copy() { 17 | CMediaMusic copy = new CMediaMusic(); 18 | return copy; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /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/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/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 final 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/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 | import net.mslivo.pixelui.engine.actions.common.ItemCellColor; 7 | import net.mslivo.pixelui.engine.actions.common.ItemIcons; 8 | 9 | public interface ComboBoxAction extends CommonActions, Displayable { 10 | 11 | default void onItemSelected(ComboBoxItem selectedItem) { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /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/Grid.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | import com.badlogic.gdx.utils.Array; 4 | import net.mslivo.pixelui.engine.actions.GridAction; 5 | 6 | public final class Grid extends Component { 7 | public T[][] items; 8 | public GridAction gridAction; 9 | public T selectedItem; 10 | public boolean multiSelect; 11 | public Array selectedItems; 12 | public boolean dragEnabled; 13 | public boolean dragOutEnabled; 14 | public boolean dragInEnabled; 15 | public boolean bigMode; 16 | 17 | Grid() { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/engine/actions/common/ItemIcons.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 ItemIcons { 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/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/UpdateAction.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine.actions.common; 2 | 3 | public abstract class UpdateAction { 4 | 5 | public final int interval; 6 | 7 | public long timer; 8 | 9 | public UpdateAction() { 10 | this(0, false); 11 | } 12 | 13 | public UpdateAction(int interval) { 14 | this(interval, false); 15 | } 16 | 17 | public UpdateAction(int interval, boolean updateOnInit) { 18 | this.interval = interval; 19 | this.timer = updateOnInit ? interval: 0 ; 20 | } 21 | 22 | public void onUpdate() { 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/media/CMediaSoundEffect.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import net.mslivo.pixelui.utils.helper.Copyable; 4 | 5 | public final class CMediaSoundEffect extends CMediaSound implements Copyable { 6 | 7 | public CMediaSoundEffect() { 8 | super(); 9 | } 10 | 11 | public CMediaSoundEffect(String filename) { 12 | super(filename); 13 | } 14 | 15 | @Override 16 | public CMediaSoundEffect copy() { 17 | CMediaSoundEffect copy = new CMediaSoundEffect(); 18 | copy.copyFields(this); 19 | return copy; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /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/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 final 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/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 | -------------------------------------------------------------------------------- /assets/shaders/pixelui/default.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 | void main(){ 7 | } 8 | 9 | // END VERTEX 10 | 11 | // BEGIN FRAGMENT 12 | 13 | vec4 colorTintAdd(vec4 color, vec4 modColor){ 14 | color.rgb = clamp(color.rgb+(modColor.rgb-0.5), 0.0, 1.0); 15 | color.a *= modColor.a; 16 | return color; 17 | } 18 | 19 | void main(){ 20 | gl_FragColor = colorTintAdd(texture2D(u_texture, v_texCoord), v_color); 21 | } 22 | 23 | // END FRAGMENT 24 | -------------------------------------------------------------------------------- /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/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/media/CMediaImage.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import net.mslivo.pixelui.utils.helper.Copyable; 4 | 5 | public final class CMediaImage extends CMediaSprite implements Copyable { 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/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 final 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/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 final 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 | -------------------------------------------------------------------------------- /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 | void main(){ 7 | } 8 | 9 | // END VERTEX 10 | 11 | // BEGIN FRAGMENT 12 | 13 | void main(){ 14 | 15 | vec2 texCoords = v_texCoord; 16 | float pixelSize = 2.0 + floor(v_tweak.x * 14.0); 17 | texCoords = texCoords * u_textureSize; 18 | texCoords = mix(texCoords, floor((texCoords / pixelSize) + 0.5) * pixelSize, step(0.001, v_tweak.x)); 19 | texCoords = texCoords / u_textureSize; 20 | gl_FragColor = texture2D(u_texture, texCoords); 21 | 22 | } 23 | 24 | // END FRAGMENT -------------------------------------------------------------------------------- /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 com.badlogic.gdx.utils.ObjectSet; 6 | import net.mslivo.pixelui.engine.actions.ListAction; 7 | 8 | public final class List extends Component { 9 | public Array items; 10 | public float scrolled; 11 | public ListAction listAction; 12 | public Color fontColor; 13 | public T selectedItem; // singleselect 14 | public boolean multiSelect; 15 | public Array selectedItems; // multiselect 16 | public boolean dragEnabled; 17 | public boolean dragOutEnabled; 18 | public boolean dragInEnabled; 19 | 20 | List() { 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /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.common.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/media/CMediaSound.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | public sealed abstract class CMediaSound extends CMedia permits CMediaSoundEffect, CMediaMusic { 4 | 5 | public CMediaSound() { 6 | super(); 7 | } 8 | 9 | public CMediaSound(String filename) { 10 | super(filename); 11 | } 12 | 13 | public CMediaSound copy() { 14 | CMediaSound copy = switch (this) { 15 | case CMediaMusic cMediaMusic -> cMediaMusic.copy(); 16 | case CMediaSoundEffect cMediaSoundEffect -> cMediaSoundEffect.copy(); 17 | }; 18 | return copy; 19 | } 20 | 21 | protected void copyFields(CMediaSound copyFrom) { 22 | super.copyFields(copyFrom); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /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.common.UpdateActionSupport; 5 | 6 | public abstract sealed class Component extends UpdateActionSupport 7 | permits AppViewport, Button, Checkbox, ComboBox, FrameBufferViewport, Grid, Image, Knob, List, Progressbar, Scrollbar, Tabbar, Text, TextField { 8 | public int x, y, width, height; 9 | public Color color; 10 | public Color color2; 11 | public boolean disabled; 12 | public boolean visible; 13 | public Tab addedToTab; 14 | public String name; 15 | public Object data; 16 | public Window addedToWindow; // set by engine 17 | public boolean addedToScreen; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /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 | static void main(String[] args) { 10 | PixelUILaunchConfig pixelUILaunchConfig = new PixelUILaunchConfig(); 11 | pixelUILaunchConfig.appTile = ExampleMainConstants.APP_TITLE; 12 | pixelUILaunchConfig.resolutionWidth = ExampleMainConstants.INTERNAL_RESOLUTION_WIDTH; 13 | pixelUILaunchConfig.resolutionHeight = ExampleMainConstants.INTERNAL_RESOLUTION_HEIGHT; 14 | pixelUILaunchConfig.windowsGLEmulation = PixelUILaunchConfig.GLEmulation.GL32_OPENGL; 15 | Tools.App.launch(new ExampleMain(), pixelUILaunchConfig); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/engine/WindowGenerator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | public final 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/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.common.UpdateActionSupport; 6 | import net.mslivo.pixelui.engine.actions.WindowAction; 7 | 8 | public final class Window extends UpdateActionSupport { 9 | public int x, y, width, height; 10 | public String title; 11 | public Color fontColor; 12 | public Array components; 13 | public String name; 14 | public Object data; 15 | public Color color; 16 | public boolean alwaysOnTop; 17 | public boolean folded; 18 | public boolean moveAble; 19 | public boolean hasTitleBar; 20 | public boolean visible; 21 | public boolean enforceScreenBounds; 22 | public WindowAction windowAction; 23 | public boolean addedToScreen; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /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/persistence/settings/validator/DecimalValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.validator; 2 | 3 | 4 | import net.mslivo.pixelui.utils.persistence.settings.SettingsManager; 5 | import net.mslivo.pixelui.utils.persistence.settings.ValueValidator; 6 | 7 | public class DecimalValueValidator implements ValueValidator { 8 | 9 | public final float rangeFrom, rangeTo; 10 | 11 | public DecimalValueValidator() { 12 | this(Float.MIN_VALUE, Float.MAX_VALUE); 13 | } 14 | 15 | public DecimalValueValidator(float rangeFrom, float rangeTo) { 16 | this.rangeFrom = rangeFrom; 17 | this.rangeTo = Math.max(rangeTo, rangeFrom); 18 | } 19 | 20 | @Override 21 | public boolean isValueValid(String value) { 22 | if (!SettingsManager.isValidDecimal(value)) return false; 23 | try { 24 | float v = Float.parseFloat(value); 25 | return v >= rangeFrom && v <= rangeTo; 26 | } catch (Exception e) { 27 | return false; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/persistence/settings/validator/NumberValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.validator; 2 | 3 | 4 | import net.mslivo.pixelui.utils.persistence.settings.SettingsManager; 5 | import net.mslivo.pixelui.utils.persistence.settings.ValueValidator; 6 | 7 | public class NumberValueValidator implements ValueValidator { 8 | 9 | public final int rangeFrom, rangeTo; 10 | 11 | public NumberValueValidator() { 12 | this(Integer.MIN_VALUE, Integer.MAX_VALUE); 13 | } 14 | 15 | public NumberValueValidator(int rangeFrom, int rangeTo) { 16 | this.rangeFrom = rangeFrom; 17 | this.rangeTo = Math.max(rangeTo, rangeFrom); 18 | } 19 | 20 | @Override 21 | public boolean isValueValid(String value) { 22 | if (!SettingsManager.isValidNumber(value)) return false; 23 | try { 24 | int v = Integer.parseInt(value); 25 | return v >= rangeFrom && v <= rangeTo; 26 | } catch (Exception e) { 27 | return false; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/engine/constants/TileSize.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine.constants; 2 | 3 | public class TileSize { 4 | 5 | public final int TS; 6 | public final int TS_HALF; 7 | public final int TS_1_AND_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 abs(int tiles) { 18 | return (tiles * TS); 19 | } 20 | 21 | public float absF(float tiles) { 22 | return (tiles * TS); 23 | } 24 | 25 | public TileSize(int tileSize) { 26 | this.TS = tileSize; 27 | this.TS_HALF = tileSize / 2; 28 | this.TS_1_AND_HALF = tileSize + (tileSize/2); 29 | this.TS2 = tileSize * 2; 30 | this.TS3 = tileSize * 3; 31 | this.TS4 = tileSize * 4; 32 | this.TSF = (float) tileSize; 33 | this.TLF_HALF = TSF / 2f; 34 | this.TSF2 = TSF * 2f; 35 | this.TSF3 = TSF * 3f; 36 | this.TSF4 = TSF * 4f; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/Transition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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_ORDER getRenderOrder(); 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/media/CMedia.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import java.util.Objects; 4 | 5 | public abstract sealed class CMedia permits CMediaFont, CMediaSound, CMediaSprite { 6 | 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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/persistence/settings/validator/EnumValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.validator; 2 | 3 | 4 | import net.mslivo.pixelui.utils.persistence.settings.SettingsManager; 5 | import net.mslivo.pixelui.utils.persistence.settings.ValueValidator; 6 | 7 | import java.util.HashSet; 8 | 9 | public class EnumValueValidator implements ValueValidator { 10 | private final Class c; 11 | private final HashSet allowedValuesSet; 12 | 13 | public EnumValueValidator(Class enumClass) { 14 | this(enumClass, null); 15 | } 16 | 17 | public EnumValueValidator(Class enumClass, Enum[] allowedValues) { 18 | this.c = enumClass; 19 | this.allowedValuesSet = new HashSet<>(); 20 | if (allowedValues != null) { 21 | for (int i = 0; i < allowedValues.length; i++) { 22 | if (allowedValues[i] != null) allowedValuesSet.add(allowedValues[i]); 23 | } 24 | } 25 | } 26 | 27 | @Override 28 | public boolean isValueValid(String value) { 29 | if (!SettingsManager.isValidEnum(value, c)) return false; 30 | if (!this.allowedValuesSet.isEmpty() && !this.allowedValuesSet.contains(Enum.valueOf(c, value))) return false; 31 | return true; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 | import net.mslivo.pixelui.engine.actions.common.ItemIcons; 9 | 10 | public interface GridAction extends CommonActions, ItemIcons, ItemCellColor { 11 | 12 | default Tooltip toolTip(T gridItem) { 13 | return null; 14 | } 15 | 16 | default boolean onItemSelected(T gridItem) { 17 | return true; 18 | } 19 | 20 | default void onDragFromGrid(Grid fromGrid, int from_x, int from_y, int to_x, int to_y) { 21 | } 22 | 23 | default void onDragFromList(List fromList, int fromIndex, int to_x, int to_y) { 24 | } 25 | 26 | default boolean canDragFromGrid(Grid fromGrid) { 27 | return false; 28 | } 29 | 30 | default boolean canDragFromList(List fromList) { 31 | return false; 32 | } 33 | 34 | default void onDragIntoApp(T gridItem, int from_x, int from_y, int screenX, int screenY) { 35 | } 36 | 37 | default boolean canDragIntoApp() { 38 | return false; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/basic/ImmediateTransition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.transitions.basic; 2 | 3 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 4 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_RENDER_ORDER; 5 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_SPEED; 6 | import net.mslivo.pixelui.utils.systems.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_ORDER getRenderOrder() { 17 | return TRANSITION_RENDER_ORDER.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/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 | } -------------------------------------------------------------------------------- /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 | void main(){ 7 | } 8 | 9 | // END VERTEX 10 | 11 | // BEGIN FRAGMENT 12 | 13 | vec4 blur(vec2 texCoords, sampler2D texture, vec2 textureSize) { 14 | vec2 texelSize = 1.0 / textureSize; 15 | vec4 color = texture2D(texture, texCoords) * 4.0;// Center pixel 16 | color += texture2D(texture, texCoords + vec2(texelSize.x, 0.0)); 17 | color += texture2D(texture, texCoords - vec2(texelSize.x, 0.0)); 18 | color += texture2D(texture, texCoords + vec2(0.0, texelSize.y)); 19 | color += texture2D(texture, texCoords - vec2(0.0, 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 | color += texture2D(texture, texCoords - vec2(texelSize.x, -texelSize.y)); 24 | return color / 12.0;// Normalize 25 | } 26 | 27 | void main(){ 28 | 29 | vec4 color = texture2D(u_texture, v_texCoord); 30 | vec4 blurred = blur(v_texCoord, u_texture, u_textureSize); 31 | 32 | gl_FragColor = mix(color, blurred, v_tweak.x); 33 | } 34 | 35 | // END FRAGMENT -------------------------------------------------------------------------------- /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 | import net.mslivo.pixelui.engine.actions.common.ItemIcons; 9 | 10 | public interface ListAction extends CommonActions, ItemIcons, ItemCellColor { 11 | 12 | default Tooltip toolTip(T listItem) { 13 | return null; 14 | } 15 | 16 | default String text(T listItem) { 17 | return listItem.toString(); 18 | } 19 | 20 | default boolean onItemSelected(T listItem) { 21 | return true; 22 | } 23 | 24 | default void onScrolled(float scrolled) { 25 | } 26 | 27 | /* Drag */ 28 | 29 | default void onDragFromList(List fromList, int fromIndex, int toIndex) { 30 | } 31 | 32 | default void onDragFromGrid(Grid fromGrid, int from_x, int from_y, int toIndex) { 33 | } 34 | 35 | default boolean canDragFromList(List list) { 36 | return false; 37 | } 38 | 39 | default boolean canDragFromGrid(Grid fromGrid) { 40 | return false; 41 | } 42 | 43 | default void onDragIntoApp(T listItem, int mouseX, int mouseY) { 44 | } 45 | 46 | default boolean canDragIntoApp() { 47 | return false; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/media/CMediaFontSymbolSingle.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import net.mslivo.pixelui.utils.helper.Copyable; 4 | 5 | public final class CMediaFontSymbolSingle extends CMediaFontSymbol implements Copyable { 6 | public int id; 7 | 8 | public CMediaFontSymbolSingle() { 9 | super(); 10 | this.id = 0; 11 | } 12 | 13 | public CMediaFontSymbolSingle(int id, String file) { 14 | this(id, file,0,0); 15 | } 16 | 17 | public CMediaFontSymbolSingle(int id, String file, int y_offset) { 18 | this(id, file,y_offset,0); 19 | } 20 | 21 | public CMediaFontSymbolSingle(int id, String file, int y_offset, int x_advance) { 22 | super(file, y_offset, x_advance); 23 | this.id = id; 24 | } 25 | 26 | @Override 27 | public CMediaFontSymbolSingle copy(){ 28 | CMediaFontSymbolSingle copy = new CMediaFontSymbolSingle(); 29 | copy.copyFields(this); 30 | copy.id = this.id; 31 | return copy; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (o == null || getClass() != o.getClass()) return false; 37 | if (!super.equals(o)) return false; 38 | 39 | CMediaFontSymbolSingle that = (CMediaFontSymbolSingle) o; 40 | return id == that.id; 41 | } 42 | 43 | @Override 44 | public int hashCode() { 45 | int result = super.hashCode(); 46 | result = 31 * result + id; 47 | return result; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/media/CMediaSprite.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | public sealed abstract class CMediaSprite extends CMedia permits CMediaImage, CMediaArray, CMediaAnimation { 4 | 5 | public boolean useAtlas; 6 | 7 | public CMediaSprite() { 8 | super(); 9 | this.useAtlas = true; 10 | } 11 | 12 | 13 | public CMediaSprite(String filename, boolean useAtlas) { 14 | super(filename); 15 | this.useAtlas = useAtlas; 16 | } 17 | 18 | public CMediaSprite copy() { 19 | CMediaSprite copy = switch (this) { 20 | case CMediaAnimation cMediaAnimation -> cMediaAnimation.copy(); 21 | case CMediaArray cMediaArray -> cMediaArray.copy(); 22 | case CMediaImage cMediaImage -> cMediaImage.copy(); 23 | }; 24 | return copy; 25 | } 26 | 27 | protected void copyFields(CMediaSprite copyFrom) { 28 | super.copyFields(copyFrom); 29 | this.useAtlas = copyFrom.useAtlas; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object object) { 34 | if (object == null || getClass() != object.getClass()) return false; 35 | if (!super.equals(object)) return false; 36 | 37 | CMediaSprite that = (CMediaSprite) object; 38 | return useAtlas == that.useAtlas; 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | int result = super.hashCode(); 44 | result = 31 * result + Boolean.hashCode(useAtlas); 45 | return result; 46 | } 47 | 48 | } 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 | void main(){ 7 | } 8 | 9 | // END VERTEX 10 | 11 | // BEGIN FRAGMENT 12 | 13 | uniform sampler2D u_lut; 14 | uniform vec2 u_lutSize; 15 | 16 | vec3 lut(vec3 color, sampler2D lutTexture, vec2 lutTextureSize) { 17 | float lutSize = lutTextureSize.y; 18 | float sliceSize = 1.0 / lutSize; 19 | float slicePixelSize = sliceSize / lutSize; 20 | float width = lutSize - 1.0; 21 | float sliceInnerSize = slicePixelSize * width; 22 | 23 | float zSlice0 = floor(color.z * width); 24 | float zSlice1 = min(zSlice0 + 1.0, width); 25 | float xOffset = slicePixelSize * 0.5 + color.x * sliceInnerSize; 26 | float yRange = (color.y * width + 0.5) / lutSize; 27 | float s0 = xOffset + (zSlice0 * sliceSize); 28 | float s1 = xOffset + (zSlice1 * sliceSize); 29 | 30 | vec3 slice0Color = texture2D(lutTexture, vec2(s0, yRange)).rgb; 31 | vec3 slice1Color = texture2D(lutTexture, vec2(s1, yRange)).rgb; 32 | 33 | float zOffset = mod(color.z * width, 1.0); 34 | 35 | return mix(slice0Color, slice1Color, zOffset); 36 | } 37 | 38 | 39 | 40 | void main(){ 41 | 42 | vec4 color = texture2D(u_texture, v_texCoord); 43 | vec4 lutColor = vec4(lut(color.rgb, u_lut, u_lutSize), color.a); 44 | 45 | gl_FragColor = mix(color, lutColor, v_tweak.x); 46 | 47 | } 48 | 49 | // END FRAGMENT -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/helper/UpdateTimer.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.helper; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | 5 | public class UpdateTimer { 6 | 7 | private float accumulator; 8 | private float timeStep; 9 | private float maxAccumulated; 10 | private static final int DEFAULT_FRAME_ACCUMULATE = 2; 11 | 12 | public UpdateTimer(int maxUpdatesPerSecond) { 13 | setTargetUpdates(maxUpdatesPerSecond, DEFAULT_FRAME_ACCUMULATE); 14 | } 15 | 16 | public UpdateTimer(int maxUpdatesPerSecond, int maxAccumulatedSteps) { 17 | setTargetUpdates(maxUpdatesPerSecond,maxAccumulatedSteps); 18 | } 19 | 20 | public void setTargetUpdates(int maxUpdatesPerSecond) { 21 | setTargetUpdates(maxUpdatesPerSecond,DEFAULT_FRAME_ACCUMULATE); 22 | } 23 | 24 | public void setTargetUpdates(int maxUpdatesPerSecond, int maxAccumulatedSteps) { 25 | maxUpdatesPerSecond = Math.max(maxUpdatesPerSecond, 1); 26 | maxAccumulatedSteps = Math.max(maxAccumulatedSteps, 1); 27 | timeStep = 1f / (float)maxUpdatesPerSecond; 28 | maxAccumulated = timeStep * maxAccumulatedSteps; 29 | accumulator = 0f; 30 | } 31 | 32 | public boolean shouldUpdate() { 33 | accumulator = Math.min(accumulator+Gdx.graphics.getDeltaTime(),maxAccumulated); 34 | 35 | if (accumulator >= timeStep) { 36 | accumulator -= timeStep; 37 | return true; 38 | } 39 | 40 | return false; 41 | } 42 | 43 | public float delta() { 44 | return timeStep; // fixed delta per update 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /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), 5 | DOWN("Down", 0, -1), 6 | LEFT("Left", -1, 0), 7 | RIGHT("Right", 1, 0), 8 | NONE("None", 0, 0); 9 | 10 | public final String text; 11 | public final int dx; 12 | public final int dy; 13 | public static final DIRECTION[] VALUES = DIRECTION.values(); 14 | 15 | DIRECTION(String text, int dx, int dy) { 16 | this.text = text; 17 | this.dx = dx; 18 | this.dy = dy; 19 | } 20 | 21 | public DIRECTION flipX() { 22 | return switch (this) { 23 | case UP -> UP; 24 | case DOWN -> DOWN; 25 | case LEFT -> RIGHT; 26 | case RIGHT -> LEFT; 27 | case NONE -> NONE; 28 | }; 29 | } 30 | 31 | public DIRECTION flipY() { 32 | return switch (this) { 33 | case UP -> DOWN; 34 | case DOWN -> UP; 35 | case LEFT -> LEFT; 36 | case RIGHT -> RIGHT; 37 | case NONE -> NONE; 38 | }; 39 | } 40 | 41 | public DIRECTION turnLeft() { 42 | return switch (this) { 43 | case UP -> LEFT; 44 | case DOWN -> RIGHT; 45 | case LEFT -> DOWN; 46 | case RIGHT -> UP; 47 | case NONE -> NONE; 48 | }; 49 | } 50 | 51 | public DIRECTION turnRight() { 52 | return switch (this) { 53 | case UP -> RIGHT; 54 | case DOWN -> LEFT; 55 | case LEFT -> UP; 56 | case RIGHT -> DOWN; 57 | case NONE -> NONE; 58 | }; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/persistence/settings/persistor/PropertiesFilePersistor.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.persistor; 2 | 3 | import com.badlogic.gdx.utils.GdxRuntimeException; 4 | import net.mslivo.pixelui.utils.Tools; 5 | import net.mslivo.pixelui.utils.persistence.settings.SettingsPersistor; 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.forceDirectoryExists(file.getParent())) { 24 | properties.store(Files.newOutputStream(file), null); 25 | } 26 | } catch (IOException e) { 27 | throw new GdxRuntimeException(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 GdxRuntimeException(e); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /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.reset(); 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.reset(); 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/persistence/settings/validator/StringValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.validator; 2 | 3 | import com.badlogic.gdx.utils.ObjectSet; 4 | import net.mslivo.pixelui.utils.persistence.settings.SettingsManager; 5 | import net.mslivo.pixelui.utils.persistence.settings.ValueValidator; 6 | 7 | public class StringValueValidator implements ValueValidator { 8 | 9 | private final ObjectSet allowedValuesSet; 10 | 11 | private final int lengthMin, lengthMax; 12 | 13 | public StringValueValidator() { 14 | this(null, Integer.MIN_VALUE, Integer.MAX_VALUE); 15 | } 16 | 17 | public StringValueValidator(String[] allowedValues) { 18 | this(allowedValues, Integer.MIN_VALUE, Integer.MAX_VALUE); 19 | } 20 | 21 | public StringValueValidator(int lengthMin, int lengthMax) { 22 | this(null, Integer.MIN_VALUE, Integer.MAX_VALUE); 23 | } 24 | 25 | public StringValueValidator(String[] allowedValues, int lengthMin, int lengthMax) { 26 | this.lengthMin = lengthMin; 27 | this.lengthMax = lengthMax; 28 | this.allowedValuesSet = new ObjectSet<>(); 29 | if (allowedValues != null) { 30 | for (int i = 0; i < allowedValues.length; i++) { 31 | if (allowedValues[i] != null) allowedValuesSet.add(allowedValues[i]); 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public boolean isValueValid(String value) { 38 | if (!SettingsManager.isValidString(value)) return false; 39 | if (!this.allowedValuesSet.isEmpty() && !this.allowedValuesSet.contains(value)) return false; 40 | return value.length() >= lengthMin && value.length() <= lengthMax; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /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 | void main(){ 7 | } 8 | 9 | // END VERTEX 10 | 11 | // BEGIN FRAGMENT 12 | 13 | vec4 colorTintAdd(vec4 color, vec4 modColor){ 14 | color.rgb = clamp(color.rgb+(modColor.rgb-0.5), 0.0, 1.0); 15 | color.a *= modColor.a; 16 | return color; 17 | } 18 | 19 | vec4 hsl2rgb(vec4 c) 20 | { 21 | const float eps = 1.0e-10; 22 | const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); 23 | vec3 p = abs(fract(c.x + K.xyz) * 6.0 - K.www); 24 | float v = (c.z + c.y * min(c.z, 1.0 - c.z)); 25 | return vec4(v * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), 2.0 * (1.0 - c.z / (v + eps))), c.w); 26 | } 27 | 28 | vec4 rgb2hsl(vec4 c) 29 | { 30 | const float eps = 1.0e-10; 31 | const vec4 J = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); 32 | vec4 p = mix(vec4(c.bg, J.wz), vec4(c.gb, J.xy), step(c.b, c.g)); 33 | vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); 34 | float d = q.x - min(q.w, q.y); 35 | float l = q.x * (1.0 - 0.5 * d / (q.x + eps)); 36 | 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); 37 | } 38 | 39 | void main(){ 40 | 41 | vec4 color = colorTintAdd(texture2D(u_texture, v_texCoord), v_color); 42 | 43 | vec4 hsl = rgb2hsl(color); 44 | hsl.x = fract(hsl.x + (v_tweak.x-0.5)); 45 | hsl.y = clamp(hsl.y + ((v_tweak.y-0.5)*2.0), 0.0, 1.0); 46 | hsl.z = clamp(hsl.z + ((v_tweak.z-0.5)*2.0), 0.0, 1.0); 47 | gl_FragColor = hsl2rgb(hsl); 48 | 49 | } 50 | // END FRAGMENT 51 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/media/CMediaFontSymbol.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import java.util.Objects; 4 | 5 | public sealed abstract class CMediaFontSymbol permits CMediaFontSymbolArray, CMediaFontSymbolSingle { 6 | public String file; 7 | public int y_offset; 8 | public int x_advance; 9 | 10 | public CMediaFontSymbol() { 11 | super(); 12 | this.y_offset = 0; 13 | this.x_advance = 0; 14 | } 15 | 16 | public CMediaFontSymbol(String file, int y_offset, int x_advance) { 17 | this.file = file; 18 | this.y_offset = y_offset; 19 | this.x_advance = x_advance; 20 | } 21 | 22 | public CMediaFontSymbol copy() { 23 | CMediaFontSymbol copy = switch (this) { 24 | case CMediaFontSymbolArray cMediaFontArraySymbol -> cMediaFontArraySymbol.copy(); 25 | case CMediaFontSymbolSingle cMediaFontSingleSymbol -> cMediaFontSingleSymbol.copy(); 26 | }; 27 | return copy; 28 | } 29 | 30 | protected void copyFields(CMediaFontSymbol copyFrom) { 31 | this.file = copyFrom.file; 32 | this.y_offset = copyFrom.y_offset; 33 | this.x_advance = copyFrom.x_advance; 34 | } 35 | 36 | @Override 37 | public boolean equals(Object object) { 38 | if (object == null || getClass() != object.getClass()) return false; 39 | 40 | CMediaFontSymbol that = (CMediaFontSymbol) object; 41 | return y_offset == that.y_offset && x_advance == that.x_advance && Objects.equals(file, that.file); 42 | } 43 | 44 | @Override 45 | public int hashCode() { 46 | int result = Objects.hashCode(file); 47 | result = 31 * result + y_offset; 48 | result = 31 * result + x_advance; 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/media/CMediaFontOutline.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import com.badlogic.gdx.graphics.Color; 4 | import net.mslivo.pixelui.utils.helper.Copyable; 5 | 6 | import java.util.Objects; 7 | 8 | public class CMediaFontOutline implements Copyable { 9 | public Color color; 10 | public int directions; 11 | public boolean outlineSymbols; 12 | public boolean outlineOnly; 13 | 14 | public CMediaFontOutline(){ 15 | super(); 16 | this.color = new Color(0f,0f,0f,0f); 17 | this.directions = 0; 18 | this.outlineSymbols = false; 19 | this.outlineOnly = false; 20 | } 21 | 22 | public CMediaFontOutline(Color color, int directions, boolean outlineSymbols, boolean outlineOnly) { 23 | this.color = new Color(color); 24 | this.directions = directions; 25 | this.outlineSymbols = outlineSymbols; 26 | this.outlineOnly = outlineOnly; 27 | } 28 | 29 | @Override 30 | public CMediaFontOutline copy(){ 31 | CMediaFontOutline copy = new CMediaFontOutline(); 32 | copy.color = new Color(this.color); 33 | copy.directions = this.directions; 34 | copy.outlineSymbols = this.outlineSymbols; 35 | copy.outlineOnly = this.outlineOnly; 36 | return copy; 37 | } 38 | 39 | @Override 40 | public boolean equals(Object o) { 41 | if (o == null || getClass() != o.getClass()) return false; 42 | 43 | CMediaFontOutline that = (CMediaFontOutline) o; 44 | return directions == that.directions && outlineSymbols == that.outlineSymbols && outlineOnly == that.outlineOnly && Objects.equals(color, that.color); 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | int result = Objects.hashCode(color); 50 | result = 31 * result + directions; 51 | result = 31 * result + Boolean.hashCode(outlineSymbols); 52 | result = 31 * result + Boolean.hashCode(outlineOnly); 53 | return result; 54 | } 55 | } -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/basic/FallOutTransition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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.systems.transitions.TRANSITION_RENDER_ORDER; 7 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_SPEED; 8 | import net.mslivo.pixelui.utils.systems.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_ORDER getRenderOrder() { 26 | return TRANSITION_RENDER_ORDER.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/systems/transitions/basic/ZoomInTransition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.transitions.basic; 2 | 3 | 4 | import com.badlogic.gdx.graphics.Color; 5 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 6 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_RENDER_ORDER; 7 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_SPEED; 8 | import net.mslivo.pixelui.utils.systems.transitions.Transition; 9 | import net.mslivo.pixelui.rendering.SpriteRenderer; 10 | 11 | public class ZoomInTransition extends Transition { 12 | private float zoom, zoomAcc; 13 | private int screenWidth; 14 | private int screenHeight; 15 | 16 | public ZoomInTransition() { 17 | super(); 18 | } 19 | 20 | public ZoomInTransition(TRANSITION_SPEED transitionSpeed) { 21 | super(transitionSpeed); 22 | } 23 | 24 | @Override 25 | public TRANSITION_RENDER_ORDER getRenderOrder() { 26 | return TRANSITION_RENDER_ORDER.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 = 0f; 34 | this.zoomAcc = 0.02f; 35 | } 36 | 37 | @Override 38 | public boolean update() { 39 | this.zoom += zoomAcc; 40 | return this.zoom > 1f; 41 | } 42 | 43 | @Override 44 | public void renderFrom(SpriteRenderer spriteRenderer, TextureRegion texture_from) { 45 | spriteRenderer.setColor(0.5f,0.5f,0.5f,1f-zoom); 46 | spriteRenderer.draw(texture_from, -screenWidth*(zoom/2f),-screenHeight*(zoom/2f),screenWidth*(zoom+1), screenHeight*(zoom+1)); 47 | spriteRenderer.setColor(Color.GRAY); 48 | } 49 | 50 | @Override 51 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) { 52 | spriteRenderer.draw(texture_to, 0, 0); 53 | } 54 | 55 | @Override 56 | public void finished(SpriteRenderer spriteRenderer) { 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /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/utils/systems/transitions/basic/ZoomOutTransition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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.systems.transitions.TRANSITION_RENDER_ORDER; 7 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_SPEED; 8 | import net.mslivo.pixelui.utils.systems.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_ORDER getRenderOrder() { 26 | return TRANSITION_RENDER_ORDER.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 | -------------------------------------------------------------------------------- /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/media/CMediaArray.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import net.mslivo.pixelui.utils.helper.Copyable; 4 | 5 | public final class CMediaArray extends CMediaSprite implements Copyable { 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 | @Override 36 | public CMediaArray copy() { 37 | CMediaArray copy = new CMediaArray(); 38 | copy.copyFields(this); 39 | copy.frameWidth = this.frameWidth; 40 | copy.frameHeight = this.frameHeight; 41 | copy.frameOffset = this.frameOffset; 42 | copy.frameLength = this.frameLength; 43 | return copy; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object o) { 48 | if (o == null || getClass() != o.getClass()) return false; 49 | if (!super.equals(o)) return false; 50 | 51 | CMediaArray that = (CMediaArray) o; 52 | return frameWidth == that.frameWidth && frameHeight == that.frameHeight && frameOffset == that.frameOffset && frameLength == that.frameLength; 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | int result = super.hashCode(); 58 | result = 31 * result + frameWidth; 59 | result = 31 * result + frameHeight; 60 | result = 31 * result + frameOffset; 61 | result = 31 * result + frameLength; 62 | return result; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /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= 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.loadState(); 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/engine/constants/DIRECTION8.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine.constants; 2 | 3 | public enum DIRECTION8 { 4 | UP("Up", 0, 1), 5 | UP_LEFT("Up Left", -1, 1), 6 | UP_RIGHT("Up Right", 1, 1), 7 | DOWN("Down", 0, -1), 8 | DOWN_LEFT("Down Left", -1, -1), 9 | DOWN_RIGHT("Down Right", 1, -1), 10 | LEFT("Left", -1, 0), 11 | RIGHT("Right", 1, 0), 12 | 13 | NONE("None", 0, 0); 14 | 15 | public final String text; 16 | public final int dx; 17 | public final int dy; 18 | public static final DIRECTION8[] VALUES = DIRECTION8.values(); 19 | 20 | DIRECTION8(String text, int dx, int dy) { 21 | this.text = text; 22 | this.dx = dx; 23 | this.dy = dy; 24 | } 25 | 26 | public DIRECTION8 flipX() { 27 | return switch (this) { 28 | case UP -> UP; 29 | case UP_LEFT -> UP_RIGHT; 30 | case UP_RIGHT -> UP_LEFT; 31 | case DOWN -> DOWN; 32 | case DOWN_LEFT -> DOWN_RIGHT; 33 | case DOWN_RIGHT -> DOWN_LEFT; 34 | case LEFT -> RIGHT; 35 | case RIGHT -> LEFT; 36 | case NONE -> NONE; 37 | }; 38 | } 39 | 40 | public DIRECTION8 flipY() { 41 | return switch (this) { 42 | case UP -> DOWN; 43 | case UP_LEFT -> DOWN_LEFT; 44 | case UP_RIGHT -> DOWN_RIGHT; 45 | case DOWN -> UP; 46 | case DOWN_LEFT -> UP_LEFT; 47 | case DOWN_RIGHT -> UP_RIGHT; 48 | case LEFT -> LEFT; 49 | case RIGHT -> RIGHT; 50 | case NONE -> NONE; 51 | }; 52 | } 53 | 54 | public DIRECTION8 turnLeft() { 55 | return switch (this) { 56 | case UP -> UP_LEFT; 57 | case UP_LEFT -> LEFT; 58 | case LEFT -> DOWN_LEFT; 59 | case DOWN_LEFT -> DOWN; 60 | case DOWN -> DOWN_RIGHT; 61 | case DOWN_RIGHT -> RIGHT; 62 | case RIGHT -> UP_RIGHT; 63 | case UP_RIGHT -> UP; 64 | case NONE -> NONE; 65 | }; 66 | } 67 | 68 | public DIRECTION8 turnRight() { 69 | return switch (this) { 70 | case UP -> UP_RIGHT; 71 | case UP_RIGHT -> RIGHT; 72 | case RIGHT -> DOWN_RIGHT; 73 | case DOWN_RIGHT -> DOWN; 74 | case DOWN -> DOWN_LEFT; 75 | case DOWN_LEFT -> LEFT; 76 | case LEFT -> UP_LEFT; 77 | case UP_LEFT -> UP; 78 | case NONE -> NONE; 79 | }; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/basic/FallInTransition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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.systems.transitions.TRANSITION_RENDER_ORDER; 7 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_SPEED; 8 | import net.mslivo.pixelui.utils.systems.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_ORDER getRenderOrder() { 32 | return TRANSITION_RENDER_ORDER.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/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/utils/persistence/settings/validator/StringListValueValidator.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.persistence.settings.validator; 2 | 3 | import com.badlogic.gdx.utils.ObjectSet; 4 | import net.mslivo.pixelui.utils.persistence.settings.SettingsManager; 5 | import net.mslivo.pixelui.utils.persistence.settings.ValueValidator; 6 | 7 | public class StringListValueValidator implements ValueValidator { 8 | private final ObjectSet allowedValuesSet; 9 | 10 | public final int listSizeMin, listSizeMax; 11 | 12 | public final int listEntryLengthMin, listEntryLengthMax; 13 | 14 | 15 | public StringListValueValidator() { 16 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE); 17 | } 18 | 19 | public StringListValueValidator(String[] allowedValues) { 20 | this(allowedValues, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE); 21 | } 22 | 23 | public StringListValueValidator(String[] allowedValues, int listSizeMin, int listSizeMax) { 24 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE); 25 | } 26 | 27 | public StringListValueValidator(int listSizeMin, int listSizeMax) { 28 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE); 29 | } 30 | 31 | public StringListValueValidator(int listSizeMin, int listSizeMax, int listEntryLengthMin, int listEntryLengthMax) { 32 | this(null, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE); 33 | } 34 | 35 | public StringListValueValidator(String[] allowedValues, int listSizeMin, int listSizeMax, int listEntryLengthMin, int listEntryLengthMax) { 36 | this.listSizeMin = listSizeMin; 37 | this.listSizeMax = listSizeMax; 38 | this.listEntryLengthMin = listEntryLengthMin; 39 | this.listEntryLengthMax = listEntryLengthMax; 40 | this.allowedValuesSet = new ObjectSet<>(); 41 | if (allowedValues != null) { 42 | for (int i = 0; i < allowedValues.length; i++) { 43 | if (allowedValues[i] != null) allowedValuesSet.add(allowedValues[i]); 44 | } 45 | } 46 | } 47 | 48 | @Override 49 | public boolean isValueValid(String value) { 50 | if (value == null) return false; 51 | String[] stringList = value.split(SettingsManager.STRING_LIST_DELIMITER); 52 | if (stringList.length < listSizeMin || stringList.length > listSizeMax) return false; 53 | for (int i = 0; i < stringList.length; i++) { 54 | if (!SettingsManager.isValidString(stringList[i])) return false; 55 | if (!this.allowedValuesSet.isEmpty() && !this.allowedValuesSet.contains(stringList[i])) return false; 56 | if (value.length() < listEntryLengthMin || value.length() > listEntryLengthMax) return false; 57 | } 58 | return true; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/utils/systems/transitions/basic/PixelateTransition.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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.systems.transitions.TRANSITION_RENDER_ORDER; 7 | import net.mslivo.pixelui.utils.systems.transitions.TRANSITION_SPEED; 8 | import net.mslivo.pixelui.utils.systems.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_ORDER getRenderOrder() { 26 | return TRANSITION_RENDER_ORDER.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.saveState(); 55 | spriteRenderer.setTweak(fadeOut,0f,0f,0f); 56 | spriteRenderer.draw(texture_from, 0, 0); 57 | spriteRenderer.loadState(); 58 | } 59 | } 60 | 61 | @Override 62 | public void renderTo(SpriteRenderer spriteRenderer, TextureRegion texture_to) { 63 | if (this.fadeOut >= 1 && this.fadeIn <= 1f) { 64 | float color = Math.clamp(fadeIn * 0.5f, 0f, 1f); 65 | spriteRenderer.saveState(); 66 | spriteRenderer.setTweak(1f-fadeIn,0f,0f,0f); 67 | spriteRenderer.draw(texture_to, 0, 0); 68 | spriteRenderer.loadState(); 69 | } 70 | 71 | } 72 | 73 | @Override 74 | public void finished(SpriteRenderer spriteRenderer) { 75 | spriteRenderer.setShader(null); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /core/src/main/java/net/mslivo/pixelui/media/CMediaFontSymbolArray.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.media; 2 | 3 | import net.mslivo.pixelui.utils.helper.Copyable; 4 | 5 | import java.util.Arrays; 6 | 7 | public final class CMediaFontSymbolArray extends CMediaFontSymbol implements Copyable { 8 | public int[] ids; 9 | public int regionWidth; 10 | public int regionHeight; 11 | public int frameOffset; 12 | public int frameLength; 13 | 14 | public CMediaFontSymbolArray() { 15 | super(); 16 | this.ids = new int[]{}; 17 | this.regionWidth = 0; 18 | this.regionHeight = 0; 19 | this.frameOffset = 0; 20 | this.frameLength = 0; 21 | } 22 | 23 | public CMediaFontSymbolArray(int[] ids, String file, int y_offset, int x_advance, int regionWidth, int regionHeight) { 24 | this(ids, file, y_offset, x_advance,regionWidth,regionHeight, 0, Integer.MAX_VALUE); 25 | } 26 | 27 | public CMediaFontSymbolArray(int[] ids, String file, int y_offset, int x_advance, int regionWidth, int regionHeight, int frameOffset, int frameLength) { 28 | super(file, y_offset, x_advance); 29 | if(ids != null){ 30 | this.ids = new int[ids.length]; 31 | System.arraycopy(ids,0,this.ids,0,ids.length); 32 | }else{ 33 | this.ids= new int[]{}; 34 | } 35 | this.regionWidth = regionWidth; 36 | this.regionHeight = regionHeight; 37 | this.frameOffset = frameOffset; 38 | this.frameLength = frameLength; 39 | } 40 | 41 | public CMediaFontSymbolArray copy(){ 42 | CMediaFontSymbolArray copy = new CMediaFontSymbolArray(); 43 | copy.copyFields(this); 44 | copy.ids = new int[this.ids.length]; 45 | for(int i=0;i { 9 | public boolean markupEnabled; 10 | public CMediaFontOutline outline; 11 | public CMediaFontSymbol[] symbols; 12 | public boolean useAtlas; 13 | 14 | public CMediaFont() { 15 | super(); 16 | this.markupEnabled = true; 17 | this.outline = null; 18 | this.symbols = new CMediaFontSymbol[]{}; 19 | this.useAtlas = true; 20 | } 21 | 22 | public CMediaFont(String file) { 23 | this(file, true, null, null); 24 | } 25 | 26 | public CMediaFont(String file, boolean markupEnabled) { 27 | this(file, markupEnabled, null, null); 28 | } 29 | 30 | public CMediaFont(String file, boolean markupEnabled, CMediaFontSymbol[] symbols) { 31 | this(file, markupEnabled, symbols, null, true); 32 | } 33 | 34 | public CMediaFont(String filename, boolean markupEnabled, CMediaFontSymbol[] symbols, CMediaFontOutline outline) { 35 | this(filename, markupEnabled, symbols, outline, true); 36 | } 37 | 38 | public CMediaFont(String filename, boolean markupEnabled, CMediaFontSymbol[] symbols, CMediaFontOutline outline, boolean useAtlas) { 39 | super(filename); 40 | this.markupEnabled = markupEnabled; 41 | this.useAtlas = useAtlas; 42 | if (symbols != null) { 43 | this.symbols = new CMediaFontSymbol[symbols.length]; 44 | for (int i = 0; i < symbols.length; i++) 45 | this.symbols[i] = symbols[i].copy(); 46 | } else { 47 | this.symbols = new CMediaFontSymbol[0]; 48 | } 49 | 50 | if (outline != null) { 51 | this.outline = new CMediaFontOutline(outline.color, outline.directions, outline.outlineSymbols, outline.outlineOnly); 52 | } else { 53 | this.outline = null; 54 | } 55 | } 56 | 57 | @Override 58 | public CMediaFont copy() { 59 | CMediaFont copy = new CMediaFont(); 60 | copy.copyFields(this); 61 | copy.markupEnabled = this.markupEnabled; 62 | copy.outline = this.outline.copy(); 63 | copy.symbols = new CMediaFontSymbol[this.symbols.length]; 64 | for (int i = 0; i < this.symbols.length; i++) 65 | copy.symbols[i] = this.symbols[i].copy(); 66 | copy.useAtlas = this.useAtlas; 67 | return copy; 68 | } 69 | 70 | @Override 71 | public boolean equals(Object o) { 72 | if (o == null || getClass() != o.getClass()) return false; 73 | if (!super.equals(o)) return false; 74 | 75 | CMediaFont that = (CMediaFont) o; 76 | return markupEnabled == that.markupEnabled && Objects.equals(outline, that.outline) && Arrays.equals(symbols, that.symbols); 77 | } 78 | 79 | @Override 80 | public int hashCode() { 81 | int result = super.hashCode(); 82 | result = 31 * result + Boolean.hashCode(markupEnabled); 83 | result = 31 * result + Objects.hashCode(outline); 84 | result = 31 * result + Arrays.hashCode(symbols); 85 | return result; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /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 | import net.mslivo.pixelui.utils.helper.Copyable; 5 | 6 | public final class CMediaAnimation extends CMediaSprite implements Copyable { 7 | 8 | public int frameWidth; 9 | public int frameHeight; 10 | public int frameOffset; 11 | public int frameLength; 12 | public float animationSpeed; 13 | public ExtendedAnimation.PlayMode playMode; 14 | 15 | public CMediaAnimation() { 16 | super(); 17 | this.frameWidth = 0; 18 | this.frameHeight = 0; 19 | this.frameOffset = 0; 20 | this.frameLength = Integer.MAX_VALUE; 21 | this.animationSpeed = 0f; 22 | this.playMode = ExtendedAnimation.PlayMode.LOOP; 23 | } 24 | 25 | public CMediaAnimation(String file, int frameWidth, int frameHeight) { 26 | this(file, frameWidth, frameHeight, 0.1f, 0, Integer.MAX_VALUE, ExtendedAnimation.PlayMode.LOOP, true); 27 | } 28 | 29 | public CMediaAnimation(String file, int frameWidth, int frameHeight, float animationSpeed) { 30 | this(file, frameWidth, frameHeight, animationSpeed, 0, Integer.MAX_VALUE, ExtendedAnimation.PlayMode.LOOP, true); 31 | } 32 | 33 | public CMediaAnimation(String file, int frameWidth, int frameHeight, float animation_speed, int frameOffset, int frameLength) { 34 | this(file, frameWidth, frameHeight, animation_speed, frameOffset, frameLength, ExtendedAnimation.PlayMode.LOOP, true); 35 | } 36 | 37 | public CMediaAnimation(String filename, int frameWidth, int frameHeight, float animationSpeed, int frameOffset, int frameLength, ExtendedAnimation.PlayMode playMode) { 38 | this(filename, frameWidth, frameHeight, animationSpeed, frameOffset, frameLength, playMode, true); 39 | } 40 | 41 | public CMediaAnimation(String filename, int frameWidth, int frameHeight, float animationSpeed, int frameOffset, int frameLength, ExtendedAnimation.PlayMode playMode, boolean useAtlas) { 42 | super(filename, useAtlas); 43 | this.frameWidth = frameWidth; 44 | this.frameHeight = frameHeight; 45 | this.animationSpeed = animationSpeed; 46 | this.frameOffset = frameOffset; 47 | this.frameLength = frameLength; 48 | this.playMode = playMode; 49 | } 50 | 51 | 52 | @Override 53 | public CMediaAnimation copy() { 54 | CMediaAnimation copy = new CMediaAnimation(); 55 | copy.copyFields(this); 56 | copy.frameWidth = this.frameWidth; 57 | copy.frameHeight = this.frameHeight; 58 | copy.animationSpeed = this.animationSpeed; 59 | copy.frameOffset = this.frameOffset; 60 | copy.frameLength = this.frameLength; 61 | copy.playMode = this.playMode; 62 | return copy; 63 | } 64 | 65 | @Override 66 | public boolean equals(Object o) { 67 | if (o == null || getClass() != o.getClass()) return false; 68 | if (!super.equals(o)) return false; 69 | 70 | CMediaAnimation that = (CMediaAnimation) o; 71 | return frameWidth == that.frameWidth && frameHeight == that.frameHeight && Float.compare(animationSpeed, that.animationSpeed) == 0 && frameOffset == that.frameOffset && frameLength == that.frameLength && playMode == that.playMode; 72 | } 73 | 74 | @Override 75 | public int hashCode() { 76 | int result = super.hashCode(); 77 | result = 31 * result + frameWidth; 78 | result = 31 * result + frameHeight; 79 | result = 31 * result + Float.hashCode(animationSpeed); 80 | result = 31 * result + frameOffset; 81 | result = 31 * result + frameLength; 82 | result = 31 * result + playMode.hashCode(); 83 | return result; 84 | } 85 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PixelUI Engine 2 | ![](logo.png) 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 | ![](screenshot_1.png) 12 | ![](screenshot_2.png) 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | net.mslivo 6 | pixeluiengine 7 | 1.0 8 | pom 9 | 10 | 25 11 | 1.14.0 12 | 1.4.0 13 | 2.2.3 14 | net.mslivo.example.ExampleLauncherMain 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | com.badlogicgames.gdx 23 | gdx 24 | ${gdx.version} 25 | compile 26 | 27 | 28 | com.badlogicgames.gdx 29 | gdx-backend-lwjgl3 30 | ${gdx.version} 31 | compile 32 | 33 | 34 | com.badlogicgames.gdx 35 | gdx-platform 36 | ${gdx.version} 37 | natives-desktop 38 | compile 39 | 40 | 41 | 42 | 43 | 44 | com.badlogicgames.gdx-controllers 45 | gdx-controllers-core 46 | ${gdx-controllers.version} 47 | compile 48 | 49 | 50 | com.badlogicgames.gdx-controllers 51 | gdx-controllers-desktop 52 | ${gdx-controllers.version} 53 | compile 54 | 55 | 56 | 57 | 58 | 59 | 60 | com.github.Dgzt 61 | gdx-lwjgl3-angle-vulkan 62 | ${lwjgl3-angle-vulkan.version} 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | gdx-nightlies 72 | https://oss.sonatype.org/content/repositories/snapshots/ 73 | 74 | 75 | gdx-releases 76 | https://oss.sonatype.org/content/repositories/releases/ 77 | 78 | 79 | jitpack.io 80 | https://jitpack.io 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | org.apache.maven.plugins 89 | maven-compiler-plugin 90 | 3.11.0 91 | 92 | ${java.version} 93 | ${java.version} 94 | 95 | 96 | 97 | org.apache.maven.plugins 98 | maven-jar-plugin 99 | 3.3.0 100 | 101 | 102 | org.apache.maven.plugins 103 | maven-assembly-plugin 104 | 3.3.0 105 | 106 | 107 | jar-with-dependencies 108 | 109 | 110 | 111 | ${mainClass} 112 | 113 | 114 | 115 | 116 | 117 | make-assembly 118 | package 119 | 120 | single 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | core 132 | desktop 133 | 134 | 135 | -------------------------------------------------------------------------------- /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.theme.Base8x8Theme; 6 | import net.mslivo.pixelui.utils.Tools; 7 | import net.mslivo.pixelui.utils.helper.UpdateTimer; 8 | import net.mslivo.pixelui.utils.systems.transitions.TransitionManager; 9 | import net.mslivo.pixelui.utils.systems.transitions.basic.PixelateTransition; 10 | import net.mslivo.pixelui.engine.UIEngine; 11 | import net.mslivo.example.ui.ExampleUIEngineAdapter; 12 | import net.mslivo.example.ui.media.ExampleBaseMedia; 13 | import net.mslivo.pixelui.utils.systems.transitions.basic.ZoomInTransition; 14 | 15 | public class ExampleMain extends ApplicationAdapter { 16 | enum STATE { 17 | RUN, TRANSITION 18 | } 19 | 20 | private STATE state; 21 | private TransitionManager transitionManager; 22 | private MediaManager mediaManager; 23 | private UIEngine uiEngine; 24 | private UIEngine uiEngine_transition; 25 | private long timer_debug_info; 26 | private UpdateTimer updateTimer; 27 | private Base8x8Theme theme8x8 = new Base8x8Theme(); 28 | 29 | public ExampleMain() { 30 | } 31 | 32 | @Override 33 | public void resize(int width, int height) { 34 | if (this.uiEngine != null) this.uiEngine.resize(width, height); 35 | } 36 | 37 | 38 | @Override 39 | public void create() { 40 | 41 | this.updateTimer = new UpdateTimer(ExampleMainConstants.UPDATE_RATE); 42 | this.transitionManager = null; 43 | // Load Assets 44 | System.out.println("Loading Assets"); 45 | 46 | 47 | this.mediaManager = new MediaManager(); 48 | this.mediaManager.prepareCMedia(theme8x8.cMedia()); 49 | this.mediaManager.prepareCMedia(ExampleBaseMedia.ALL); 50 | this.mediaManager.loadAssets(); 51 | System.out.println("Done."); 52 | 53 | // Input/Render 54 | System.out.println("Starting UI"); 55 | 56 | this.uiEngine = new UIEngine<>( 57 | new ExampleUIEngineAdapter(), 58 | this.mediaManager, theme8x8, ExampleMainConstants.INTERNAL_RESOLUTION_WIDTH, ExampleMainConstants.INTERNAL_RESOLUTION_HEIGHT, 59 | ExampleMainConstants.viewportMode,true); 60 | System.out.println("Done."); 61 | 62 | this.state = STATE.RUN; 63 | 64 | } 65 | 66 | 67 | @Override 68 | public void render() { 69 | switch (state) { 70 | 71 | case RUN -> { 72 | 73 | if (updateTimer.shouldUpdate()) { 74 | this.uiEngine.update(); 75 | } 76 | 77 | this.uiEngine.render(); 78 | 79 | // Check for transition + Reset 80 | if (this.uiEngine.getAdapter().isResetPressed()) { 81 | this.uiEngine_transition = new UIEngine<>( 82 | new ExampleUIEngineAdapter(), 83 | this.mediaManager, theme8x8, ExampleMainConstants.INTERNAL_RESOLUTION_WIDTH, ExampleMainConstants.INTERNAL_RESOLUTION_HEIGHT, 84 | ExampleMainConstants.viewportMode); 85 | this.uiEngine_transition.update(); 86 | this.transitionManager = new TransitionManager(this.uiEngine, this.uiEngine_transition, new ZoomInTransition()); 87 | this.transitionManager.render(); 88 | state = STATE.TRANSITION; 89 | return; 90 | } 91 | 92 | 93 | } 94 | case TRANSITION -> { 95 | if (updateTimer.shouldUpdate()) { 96 | boolean finished = this.transitionManager.update(); 97 | if (finished) { 98 | // Replace with new UIEngine after Reset 99 | this.uiEngine.dispose(); 100 | this.uiEngine = this.uiEngine_transition; 101 | this.uiEngine_transition = null; 102 | this.state = STATE.RUN; 103 | return; 104 | } 105 | } 106 | transitionManager.render(); 107 | } 108 | } 109 | 110 | // Debug Output 111 | if (System.currentTimeMillis() - timer_debug_info > 1000) { 112 | System.out.println(Tools.Text.benchmark()); 113 | timer_debug_info = System.currentTimeMillis(); 114 | } 115 | 116 | 117 | } 118 | 119 | @Override 120 | public void dispose() { 121 | System.out.println("Shutting down..."); 122 | this.shutdownEngine(); 123 | System.out.println("Done."); 124 | } 125 | 126 | private void shutdownEngine() { 127 | this.uiEngine.dispose(); 128 | this.mediaManager.dispose(); 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /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.*; 5 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 6 | import com.badlogic.gdx.graphics.glutils.FrameBuffer; 7 | import com.badlogic.gdx.utils.BufferUtils; 8 | 9 | import java.nio.ByteBuffer; 10 | import java.nio.ByteOrder; 11 | import java.nio.IntBuffer; 12 | 13 | /** 14 | * An implementation of Framebuffer allows nesting. 15 | * Adapted from: https://github.com/crykn/libgdx-screenmanager/wiki/Custom-FrameBuffer-implementation 16 | */ 17 | public class NestedFrameBuffer extends FrameBuffer { 18 | private static final String ERROR_END_BEGIN = "NestedFrameBuffer.end must be called before begin."; 19 | private static final String ERROR_BEGIN_END = "NestedFrameBuffer.begin must be called before end."; 20 | private int[] previousViewport; 21 | private boolean isBound; 22 | private TextureRegion textureRegionFlippedCache; 23 | private final IntBuffer intBuffer; 24 | private int[] getViewPortCache; 25 | private int previousFBOHandle; 26 | private int getBoundFBOCache; 27 | 28 | public NestedFrameBuffer(Pixmap.Format format, int width, int height) { 29 | this(format, width, height, false, false); 30 | } 31 | 32 | public NestedFrameBuffer(Pixmap.Format format, int width, int height, boolean hasDepth) { 33 | this(format, width, height, hasDepth, false); 34 | } 35 | 36 | public NestedFrameBuffer(Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil) { 37 | super(format, width, height, hasDepth, hasStencil); 38 | this.isBound = false; 39 | this.previousFBOHandle = -1; 40 | this.previousViewport = null; 41 | this.intBuffer = ByteBuffer 42 | .allocateDirect(16 * Integer.BYTES).order(ByteOrder.nativeOrder()) 43 | .asIntBuffer(); 44 | this.getBoundFBOCache = -1; 45 | this.getViewPortCache = null; 46 | this.textureRegionFlippedCache = null; 47 | } 48 | 49 | 50 | private int getBoundFboHandle() { 51 | if(this.getBoundFBOCache != -1) return this.getBoundFBOCache; 52 | Gdx.gl.glGetIntegerv(GL32.GL_FRAMEBUFFER_BINDING, this.intBuffer); 53 | this.getBoundFBOCache = this.intBuffer.get(0); 54 | return this.getBoundFBOCache; 55 | } 56 | 57 | private int[] getViewport() { 58 | if(this.getViewPortCache != null) return this.getViewPortCache; 59 | this.getViewPortCache = new int[4]; 60 | IntBuffer intBuf = intBuffer; 61 | Gdx.gl.glGetIntegerv(GL32.GL_VIEWPORT, intBuf); 62 | this.getViewPortCache[0] = intBuf.get(0); 63 | this.getViewPortCache[1] = intBuf.get(1); 64 | this.getViewPortCache[2] = intBuf.get(2); 65 | this.getViewPortCache[3] = intBuf.get(3); 66 | return this.getViewPortCache; 67 | } 68 | 69 | 70 | public void beginGlClear(){ 71 | this.begin(); 72 | Gdx.gl.glClearColor(0f, 0f, 0f, 0f); 73 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 74 | } 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 | } 107 | 108 | @Override 109 | protected void build() { 110 | int previousFBOHandle = getBoundFboHandle(); 111 | super.build(); 112 | Gdx.gl.glBindFramebuffer(GL32.GL_FRAMEBUFFER, previousFBOHandle); 113 | } 114 | 115 | public boolean isBound() { 116 | return isBound; 117 | } 118 | 119 | public void resetCaches(){ 120 | this.getViewPortCache = null; 121 | this.textureRegionFlippedCache = null; 122 | this.getBoundFBOCache = -1; 123 | } 124 | 125 | public TextureRegion getFlippedTextureRegion(){ 126 | if(this.textureRegionFlippedCache == null){ 127 | this.textureRegionFlippedCache = new TextureRegion(this.getColorBufferTexture()); 128 | this.textureRegionFlippedCache.flip(false,true); 129 | } 130 | return this.textureRegionFlippedCache; 131 | } 132 | 133 | 134 | 135 | 136 | 137 | @Override 138 | public void dispose() { 139 | super.dispose(); 140 | } 141 | } -------------------------------------------------------------------------------- /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/utils/systems/appengine/AppEngine.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.utils.systems.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 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/APINotification.java: -------------------------------------------------------------------------------- 1 | package net.mslivo.pixelui.engine; 2 | 3 | import com.badlogic.gdx.graphics.Color; 4 | import net.mslivo.pixelui.media.MediaManager; 5 | import net.mslivo.pixelui.utils.Tools; 6 | import net.mslivo.pixelui.engine.constants.TOOLTIP_NOTIFICATION_STATE; 7 | import net.mslivo.pixelui.engine.constants.TOP_NOTIFICATION_STATE; 8 | import net.mslivo.pixelui.engine.actions.NotificationAction; 9 | 10 | public final class APINotification { 11 | private final API api; 12 | private final UIEngineState uiEngineState; 13 | private final UICommonUtils uiCommonUtils; 14 | private final MediaManager mediaManager; 15 | private final UIEngineConfig uiEngineConfig; 16 | 17 | public final APITooltipNotification tooltip; 18 | 19 | APINotification(API api, UIEngineState uiEngineState, UICommonUtils uiCommonUtils, MediaManager mediaManager) { 20 | this.api = api; 21 | this.uiEngineState = uiEngineState; 22 | this.uiCommonUtils = uiCommonUtils; 23 | this.mediaManager = mediaManager; 24 | this.uiEngineConfig = uiEngineState.config; 25 | 26 | this.tooltip = new APITooltipNotification(); 27 | } 28 | 29 | public final NotificationAction DEFAULT_NOTIFICATION_ACTION = new NotificationAction() {}; 30 | 31 | public Notification create(String text) { 32 | return create(text, DEFAULT_NOTIFICATION_ACTION, false, uiEngineConfig.notification.defaultDisplayTime); 33 | } 34 | 35 | public Notification create(String text, NotificationAction notificationAction) { 36 | return create(text, notificationAction, false, uiEngineConfig.notification.defaultDisplayTime); 37 | } 38 | 39 | public Notification create(String text, NotificationAction notificationAction, boolean uiInteractionEnabled) { 40 | return create(text, notificationAction,uiInteractionEnabled, uiEngineConfig.notification.defaultDisplayTime); 41 | } 42 | 43 | public Notification create(String text, NotificationAction notificationAction, boolean uiInteractionEnabled, int displayTime) { 44 | Notification notification = new Notification(); 45 | notification.text = Tools.Text.validString(text); 46 | notification.uiInteractionEnabled = uiInteractionEnabled; 47 | notification.displayTime = Math.max(displayTime,0); 48 | notification.color = new Color(uiEngineConfig.notification.defaultColor); 49 | notification.fontColor = uiEngineConfig.ui.fontDefaultColor.cpy(); 50 | notification.notificationAction = notificationAction != null ? notificationAction : DEFAULT_NOTIFICATION_ACTION; 51 | notification.timer = 0; 52 | int textWidth = mediaManager.fontTextWidth(uiEngineConfig.ui.font, notification.text); 53 | if (textWidth > uiEngineState.resolutionWidth) { 54 | int tooMuch = (textWidth - uiEngineState.resolutionWidth); 55 | notification.state = TOP_NOTIFICATION_STATE.INIT_SCROLL; 56 | notification.scroll = -(tooMuch / 2) - 4; 57 | notification.scrollMax = (tooMuch / 2) + 4; 58 | } else { 59 | notification.state = TOP_NOTIFICATION_STATE.INIT_DISPLAY; 60 | notification.scroll = notification.scrollMax = 0; 61 | } 62 | return notification; 63 | } 64 | 65 | public void setName(Notification notification, String name) { 66 | if (notification == null) return; 67 | notification.name = Tools.Text.validString(name); 68 | } 69 | 70 | public void setData(Notification notification, Object data) { 71 | if (notification == null) return; 72 | notification.data = data; 73 | } 74 | 75 | public void setNotificationAction(Notification notification, NotificationAction notificationAction) { 76 | if (notification == null) return; 77 | notification.notificationAction = notificationAction != null ? notificationAction : DEFAULT_NOTIFICATION_ACTION; 78 | } 79 | 80 | public void setDisplayTime(Notification notification, int displayTime) { 81 | if (notification == null) return; 82 | notification.displayTime = Math.max(displayTime, 0); 83 | } 84 | 85 | public void setColor(Notification notification, Color color) { 86 | if (notification == null || color == null) return; 87 | notification.color.set(color); 88 | } 89 | 90 | public void setFontColor(Notification notification, Color color) { 91 | if (notification == null) return; 92 | notification.fontColor.set(color); 93 | } 94 | 95 | public void setText(Notification notification, String text) { 96 | if (notification == null) return; 97 | notification.text = Tools.Text.validString(text); 98 | } 99 | 100 | public final class APITooltipNotification { 101 | 102 | public TooltipNotification create(int x, int y, Tooltip tooltip){ 103 | return create(x,y,tooltip, uiEngineConfig.notification.toolTipNotificationDefaultDisplayTime); 104 | } 105 | 106 | public TooltipNotification create(int x, int y, Tooltip tooltip, int displayTime){ 107 | TooltipNotification tooltipNotification= new TooltipNotification(); 108 | tooltipNotification.x = x; 109 | tooltipNotification.y = y; 110 | tooltipNotification.tooltip = tooltip; 111 | tooltipNotification.displayTime = displayTime; 112 | tooltipNotification.timer = 0; 113 | tooltipNotification.state = TOOLTIP_NOTIFICATION_STATE.INIT; 114 | return tooltipNotification; 115 | } 116 | 117 | public void setPosition(TooltipNotification tooltipNotification, int x, int y){ 118 | if(tooltipNotification == null) 119 | return; 120 | tooltipNotification.x = x; 121 | tooltipNotification.y = y; 122 | } 123 | 124 | public void setTooltip(TooltipNotification tooltipNotification, Tooltip tooltip){ 125 | if(tooltipNotification == null) 126 | return; 127 | tooltipNotification.tooltip = tooltip; 128 | } 129 | 130 | public void setName(TooltipNotification tooltipNotification, String name) { 131 | if (tooltipNotification == null) return; 132 | tooltipNotification.name = Tools.Text.validString(name); 133 | } 134 | 135 | public void setData(TooltipNotification tooltipNotification, Object data) { 136 | if (tooltipNotification == null) return; 137 | tooltipNotification.data = data; 138 | } 139 | 140 | } 141 | 142 | 143 | 144 | 145 | 146 | 147 | } 148 | --------------------------------------------------------------------------------