{"id":23112032,"url":"https://github.com/lightaxis/cc_jlib","last_synced_at":"2025-04-03T23:44:39.102Z","repository":{"id":61900497,"uuid":"431579904","full_name":"lightAxis/CC_JLib","owner":"lightAxis","description":"Library for add ComputerCraft mod GUI \u0026 multi-screen user application","archived":false,"fork":false,"pushed_at":"2022-11-01T23:29:35.000Z","size":767,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T11:41:27.371Z","etag":null,"topics":["computercraft","computercraft-tweaked","lua"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lightAxis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-24T17:54:00.000Z","updated_at":"2022-10-29T14:21:46.000Z","dependencies_parsed_at":"2023-01-21T04:02:40.217Z","dependency_job_id":null,"html_url":"https://github.com/lightAxis/CC_JLib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightAxis%2FCC_JLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightAxis%2FCC_JLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightAxis%2FCC_JLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightAxis%2FCC_JLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lightAxis","download_url":"https://codeload.github.com/lightAxis/CC_JLib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097972,"owners_count":20883127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computercraft","computercraft-tweaked","lua"],"created_at":"2024-12-17T02:15:42.506Z","updated_at":"2025-04-03T23:44:39.083Z","avatar_url":"https://github.com/lightAxis.png","language":"Lua","readme":"# CC_JLib\r\n\r\nObject-oriented Jiseok Library used in Computercraft, including various UI apis and classes.\r\nEasy to use, optimized as possible\r\n\r\n## Features\r\n\r\n- Various UI Elements, TextArea, Border, Margin, Textblock\r\n- Easy to use UI Elements api, one-shot-rendering method\r\n- Enrionment Variable \u0026 Namespace appiled to avoid name collision with other libraries\r\n- Selection build to debug test functions in both Lua \u0026 ComputerCraft environments\r\n- Require-based package modulation, faster than using dofile function\r\n- TODO : Button API, Screen Scroll, Interactive UI API, Examples\r\n\r\n## Object Oriented Programming\r\n\r\nIn this repo, I used [middleclass](https://github.com/kikito/middleclass) apis for using OOP functions in lua languege.\r\nmiddleclass is a powerful lua OOP library able to make class, inheritance, metamethods(operator overloading), class static variable(class variable) and weak mixin functions.\r\nit is at [JLib/Class/middleclass.lua](./JLib/Class/middleclass.lua)\r\n\r\n## Packages\r\n\r\n- **Class**\r\n  OOP library for lua. using middleclass.lua\r\n- **LibGlobal**\r\n  Global variables and methods using in CC_JLib. Environment variables and global static methods like sting function overloading\r\n- **MathLib**\r\n  Mathmetics library. Vector2, Vector3 is implemented\r\n- **ReactorControl**\r\n  Controls BigReactors mode reactor. PI controller for control inner energy buffer.\r\n- **Screentext**\r\n  very very simple api to display text on screen. like banners\r\n- **UI**\r\n  all modules used in drawing \u0026 calculating UI\r\n\r\n## UI Elements\r\n\r\n- **UIElement**  \r\n  Base class for UI elements. Cannot be used as instance alone.  \r\n  Contains basic properties for UIElement. You can make your own UIElement by inherit this class\r\n\r\n  - Position, Relative Position, Length, Background \u0026 Foreground color\r\n  - UIElement itself is a node of UI Rendering Tree, Rendering Children after renders itself\r\n  - UI Event Bubbling Logic \u0026 abstract function for UIEvent handling\r\n\r\n- **Enums**  \r\n  All enums used in UI element \u0026 event in computercraft\r\n  - VerticalAlignmentMode\r\n  - HorizontalAlignmentMode\r\n  - Side\r\n  - MouseButton\r\n  - ScrollDirection\r\n  - Direction\r\n  - Key\r\n  - KeyReverse\r\n  - Color : with new Color.None(Transparent)\r\n  - Blit\r\n  - BlitReverse\r\n- **UIEvent**  \r\n  Definitions of all UI interaction struct for computercraft\r\n  - mouse click\r\n  - mouse scroll\r\n  - key input\r\n  - char input\r\n  - monitor touch\r\n- **UITools**  \r\n  Toolbox for UI position calculation, vector calculation, drawing function\r\n- **UIScene**  \r\n  Composite Class of all UIElement in one screen, like a page.  \r\n  This is a base class for all UIScenes, you can make your own UIScene by inherit this class. UIScene Offers ProjectNamespace \u0026 AttachedScreen to child class.\r\n- **UIRunner**  \r\n  Run the Multiple UIScenes with UIEvent Routing to target UIElement.  \r\n  Attach \u0026 Detach UIScene for each monitor or terminal. Recieves os.pullEvent() event with specific UIEvent, get UIElement at position, route UIEvent to clicked or touched UIElement's UIEvent handler function. Rednet message handing alse avilable.\r\n- **Screen**  \r\n  Wrapper class of ComputerCraft's native screen.  \r\n  Render duplicated Screen buffer inside by UIElements. After all rendering finished, reflect internal screen buffer to actual CC's screen. This way removes jittering problem when render a new screen from the black, clean screen every time. Normally, screen rendering \u0026 reflecting occurs only when new UIEvent or Rednet messages handled. User can also manually trigger this procedure.\r\n- **ScreenCanvas**  \r\n  Wrapper Basic UIElement of Screen class. Root node of each screen's UI Rendering Tree.  \r\n  Always follows the size of attached screen, propagates rendering function to all children.  \r\n  Length \u0026 relative position is depend on Screen\r\n- **Grid**  \r\n  UI positioning tool for other UIElements. Similar with Grid in WPF\r\n- **Margin**  \r\n  Add the margin to child UIElements.  \r\n  UIElement for positioning child UIElements.  \r\n  Length \u0026 relative position is depend on Parent UIElement\r\n- **Border**  \r\n  Add the border to child UIElements.\r\n  It does not pad or give margin to child UIElement. Just overdraw the border.  \r\n  Length \u0026 relative position is depend on Parent UIElement line to screen\r\n- **TextArea**  \r\n  Text Showing, Align, Editting function area for parent UIElement.  \r\n  Can set Text, Edit text, align horizontally \u0026 vertically. Alse can be used as a text edittor when turn on the IsEdittable=True.  \r\n  Length \u0026 relative position is depend on Parent UIElement\r\n- **TextBlock**  \r\n  Composite of Margin, Border, TextArea. Free to Edit relative position \u0026 Length\r\n- **Button**  \r\n  Child class of Textblock, adding ToggleMode, change Colors when pressed.  \r\n  Triggers Click event when clicked or monitor touched\r\n- **ListBox**  \r\n  Shows the internal custom table as the list of ListBoxItem UIElement.  \r\n  Can set internal custom table, make own display rule by set ItemTemplate function. Triggers event when SelectionChanged.\r\n- **ListBoxItem**  \r\n  Item container class of ListBox UIElement.\r\n- **ProgressBar**  \r\n  Display Progress in forms of Bar. Supports two direction : horizontal \u0026 vertical\r\n\r\n## How To Include\r\n\r\nrequire [JLib/init.lua](./init.lua). JLib must be at /CC_JLib/JLib in absolute path in yout CC computer.\r\nThan, include all UI Headers(modules) by includeing UI.Include.lua\r\n\r\n**example code**\r\n\r\n```lua\r\n-- register package.path CC_JLib path\r\nrequire(\"CC_JLib.JLib.init\")\r\n\r\n-- include all UI modules in CC_JLib\r\nrequire(\"UI.Include\")\r\n```\r\n\r\ninit.lua file has one local variable to select your running environment.\r\nIn init.lua, Also you can add new Environment number of your own\r\n\r\n**Init.lua**\r\n\r\n```lua\r\n-- select your environment\r\n-- 0 : jasuk500, 1 : CC, 2 : replit.com\r\nlocal environment = 0\r\n\r\nif (environment == 0) then\r\n    -- in another env\r\n    package.path = package.path .. \";D:/lua/CC_JLib/JLib/?.lua\"\r\n    package.path = package.path .. \";/home/jisuk500/asdf/CC_JLib/JLib/?.lua\"\r\n\r\n    require(\"LibGlobal.LibVariables\")\r\n    JLib.LibVariables.static.ENVIRONMENT =\r\n        JLib.LibVariables.static.eENVIRONMENT.Lua\r\n\r\nelseif (environment == 1) then\r\n    -- CC env\r\n    package.path = package.path .. \";CC_JLib/JLib/?.lua\"\r\n\r\n    require(\"LibGlobal.LibVariables\")\r\n    JLib.LibVariables.static.ENVIRONMENT =\r\n        JLib.LibVariables.static.eENVIRONMENT.CC\r\n\r\nelseif (environment == 2) then\r\n    -- replit env\r\n    package.path = package.path .. \";/home/runner/CCsource/JLib/?.lua\"\r\n\r\n    require(\"LibGlobal.LibVariables\")\r\n    JLib.LibVariables.static.ENVIRONMENT =\r\n        JLib.LibVariables.static.eENVIRONMENT.Lua\r\n\r\nend\r\n```\r\n\r\n## UI APIs\r\n\r\n- UIElement\r\n  abstract class for all UI element, virtual function 'render()' is included\r\n\r\n## Class Diagram\r\n\r\n![Class_diagram_png](out/doc/UML/main/ClassDiagram.png)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightaxis%2Fcc_jlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flightaxis%2Fcc_jlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightaxis%2Fcc_jlib/lists"}