Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romgerman/cgui
(WIP) Convenient (i hope so) framework for client GUI for Rust (game)
https://github.com/romgerman/cgui
csharp oxide oxidemod plugin rust umod
Last synced: 1 day ago
JSON representation
(WIP) Convenient (i hope so) framework for client GUI for Rust (game)
- Host: GitHub
- URL: https://github.com/romgerman/cgui
- Owner: romgerman
- Created: 2019-04-08T13:14:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-23T12:22:59.000Z (over 5 years ago)
- Last Synced: 2024-12-19T13:54:50.521Z (6 days ago)
- Topics: csharp, oxide, oxidemod, plugin, rust, umod
- Language: C#
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CGUI
This plugin is heavily WIP.## Files
`CGUI` — Base plugin. Contains base classes.`GUILibrary` — Requires `CGUI`. Contains basic UI elements.
`GUITest` — Is for testing.
## Usage
Firstly you need to require one of the files inside your plugin.
```csharp
// Requires: CGUI
````GUIObject` represents a basic UI element and acts as `ICollection` for components derived from `GUIComponentBase`.
**Example:**
```csharp
// Basic text UI element
var element = new GUIObject()
{
new TextComponent("Example"),
new RectTransformComponent()
};
```
To show your UI to a player you can use `GUIObject.ShowUI(BasePlayer)`.To make more advanced elements you should make your own classes derived from `GUIElementBase` or use classes from `GUILibrary`.
`GUIElementBase` allows you to easily combine basic `GUIObject` elements. To show a `GUIElementBase` element to a player you should to use `Representation` class which acts as `ICollection` for `GUIElementBase`.
**For example** this is a constructor for `GUIButton` class (`GUILibrary`):
```csharp
public GUIObject TextElement;
public GUIObject ButtonElement;public GUIButton(string text = "", string elementName = null, string parent = null)
{
elementName = elementName ?? GUIObject.GenerateId();ButtonElement = new GUIObject(elementName + "_button", parent)
{
new ButtonComponent().OnClick(player =>
{
Click?.Invoke(this, player);
}, Owner),
new RectTransformComponent()
};TextElement = new GUIObject(elementName + "_text", ButtonElement.Name)
{
new TextComponent(text) { Align = TextAlign.MiddleCenter, Color = Color.black }
};
}
```
Every class derived from `GUIElementBase` should implement its own `Render` method.**For example:**
```csharp
public override ICollection Render()
{
return new GUIObject[] { ButtonElement, TextElement };
}
```
The method is pretty straightforward. But one thing is — you should follow the inheritance order. So the previous element should be a parent of the next element.If no name is present for `GUIObject` it generates the name automatically using `GUIObject.GenerateId()`.
## Components
Currently not all supported components are presented.`RectTransformComponent` should be added at the end. Instead it will not work.
## Data binding
Data binding is WIP. Examples can be found inside `GUILibrary`.## Markup language
WIP