Added development manual.

Changed "avatar_connected" type to generic "notification" type.
Removed unused commented code.

Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>
This commit is contained in:
Armored Dragon 2024-05-25 22:41:17 -05:00
parent 60a46626d9
commit 8301bfd626
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B
3 changed files with 121 additions and 9 deletions

View file

@ -5,6 +5,7 @@
- Installation
- Settings
- Usability tips
3. Development
## What is Armored Chat
@ -52,16 +53,12 @@ Default value is `200`
This action immediately clears the AC history and the session. Functionally this will set the message list to a empty Array.
---
### Usage
AC has two chat modes: Local, and Domain. Local chat displays all other local chat messages that are within 20 units of you. Domain chat will display all other Domain messages sent though that channel regardless of distance.
AC also handles link embedding. When you send an HTTP(S) link, it will automatically parse it using Qt RichText and allow everyone to click on the message. Next to the link you will also see a "⮺" symbol. Clicking on this symbol will open the link in an external window.
---
### Usability tips
#### Navigation
@ -89,3 +86,120 @@ Supported filetypes are:
- `.bmp`
- `.svg`
- `.webp`
## Development
### To QML communication
Here are the signals needed to communicate from the JavaScript core to the QML interface.
AC calls a `_emitEvent()` function that also includes a `type` key in the object. This `type` tells the QML and/or the JS core what the packet is for.
When you call the `_emitEvent()` function be sure to include the following signals as a `type`. In the examples below, the `type` is being excluded for brevity.
Example:
```json
{ type: "show_message", displayName: "username", ...}
```
#### "show_message"
This signal tells the QML to add a new message to the ListView element list.
Supply a `JSON` object.
```json
{
"displayName": "username",
"message": "chat message",
"channel": "domain", // Channel to send message on. By default it should only be "domain" or "local".
"date": "[ time and date string ]" // Optional, defaults to current time and date.
}
```
#### "clear_messages"
Clear all messages displayed in the ListView elements. Note this does not clear the history and this is only a visual erasure.
No payload required.
#### "notification"
Renders a notification to the domain channel.
The intended use is to provide updates about the domain and make the notifications accessible.
Supply a `JSON` object.
```json
{
"message": "notification message" // Notification to render
}
```
#### "initial_settings"
Visually set the settings in the QML interface based on the supplied object.
Supply a `JSON` object.
```json
{
"settings": {
// JSON object of current AC settings
"external_window": false,
"maximum_messages": 200
}
}
```
### To JS communication
Here are the signals needed to communicate from the QML interface to the JavaScript core. AC is developed in a way that all actions that are not style related are preformed though the JavaScript core.
This means that what ever action you want to preform must go though the JavaScript core for processing.
This is formatted the same was as the communication packets to the QML interface. Supply the following entries as "type"s in your packet.
#### "send_message"
Tell AC to broadcast a message to the domain.
Supply a `JSON` object.
```json
{
"message": "message content", // The contents of the message to send.
"channel": "domain" // Channel to emit the message to.
}
```
#### "setting_change"
Tell AC to change a setting. Exercise caution when using this as you can add new settings unintentionally if you are not careful.
Supply a `JSON` object
```json
{
"setting": "external_window", // The name of the setting to change
"value": true // The value to change the setting to
}
```
#### "action"
Tell AC to preform a generic action. This is normally reserved for functions that would get called on a button onClicked event in the QML.
Supply a `JSON` object
```json
{
"action": "erase_history" // The action to preform
}
```
#### "initialized"
Tell AC the QML overlay has loaded successfully.
This is called to hide the overlay on creation.
No payload required.

View file

@ -224,7 +224,7 @@
let message = {};
message.message = `${display_name} ${type}`;
_emitEvent({ type: "avatar_connected", ...message });
_emitEvent({ type: "notification", ...message });
}, 1500);
}
function _loadSettings() {
@ -251,7 +251,7 @@
/**
* Emit a packet to the HTML front end. Easy communication!
* @param {Object} packet - The Object packet to emit to the HTML
* @param {("setting_update"|"show_message")} packet.type - The type of packet it is
* @param {("show_message"|"clear_messages"|"notification"|"initial_settings")} packet.type - The type of packet it is
*/
function _emitEvent(packet = { type: "" }) {
chat_overlay_window.sendToQml(packet);

View file

@ -59,7 +59,6 @@ Rectangle {
Behavior on width {
NumberAnimation {
duration: 50
// easing.type: Easeing.InOutQuad
}
}
@ -94,7 +93,6 @@ Rectangle {
MouseArea {
anchors.fill: parent
onClicked: {
// addMessage("usertest", "Clicked", "Now", "domain", "notification");
pageVal = "domain"
}
}
@ -537,7 +535,7 @@ Rectangle {
case "show_message":
addMessage(message.displayName, message.message, `[ ${message.timeString || time} - ${message.dateString || date} ]`, message.channel, "chat");
break;
case "avatar_connected":
case "notification":
addMessage("SYSTEM", message.message, `[ ${time} - ${date} ]`, "domain", "notification");
break;
case "clear_messages":