Skip to content

Commit 5f8daa8

Browse files
authored
Initial commit
0 parents  commit 5f8daa8

File tree

9 files changed

+871
-0
lines changed

9 files changed

+871
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.godot
2+
dist

LICENSE

Lines changed: 675 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
PLUGIN_ID ?= $(shell grep 'plugin\.id' plugin.json | awk '{print $$2}' | grep -o '"[^"]\+"' | sed 's/"//g')
2+
PLUGIN_NAME ?= $(shell grep 'plugin\.name' plugin.json | awk '{print $$2}' | grep -o '"[^"]\+"' | sed 's/"//g')
3+
4+
GODOT ?= /usr/bin/godot
5+
OPENGAMEPAD_UI_REPO ?= https://github.com/ShadowBlip/OpenGamepadUI.git
6+
OPENGAMEPAD_UI_BASE ?= ../OpenGamepadUI
7+
EXPORT_PRESETS ?= $(OPENGAMEPAD_UI_BASE)/export_presets.cfg
8+
PLUGINS_DIR := $(OPENGAMEPAD_UI_BASE)/plugins
9+
BUILD_DIR := $(OPENGAMEPAD_UI_BASE)/build
10+
INSTALL_DIR := $(HOME)/.local/share/opengamepadui/plugins
11+
12+
##@ General
13+
14+
# The help target prints out all targets with their descriptions organized
15+
# beneath their categories. The categories are represented by '##@' and the
16+
# target descriptions by '##'. The awk commands is responsible for reading the
17+
# entire set of makefiles included in this invocation, looking for lines of the
18+
# file as xyz: ## something, and then pretty-format the target and help. Then,
19+
# if there's a line with ##@ something, that gets pretty-printed as a category.
20+
# More info on the usage of ANSI control characters for terminal formatting:
21+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
22+
# More info on the awk command:
23+
# http://linuxcommand.org/lc3_adv_awk.php
24+
25+
.PHONY: help
26+
help: ## Display this help.
27+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
28+
29+
##@ Development
30+
31+
.PHONY: dist
32+
dist: build ## Build and package plugin
33+
34+
.PHONY: build
35+
build: $(PLUGINS_DIR)/$(PLUGIN_ID) export_preset ## Build the plugin
36+
@echo "Exporting plugin package"
37+
cd $(OPENGAMEPAD_UI_BASE) && $(MAKE) addons
38+
mkdir -p dist
39+
touch dist/.gdignore
40+
$(GODOT) --headless \
41+
--path $(OPENGAMEPAD_UI_BASE) \
42+
--export-pack "$(PLUGIN_NAME)" \
43+
plugins/$(PLUGIN_ID)/dist/$(PLUGIN_ID).zip
44+
cd dist && sha256sum $(PLUGIN_ID).zip > $(PLUGIN_ID).zip.sha256.txt
45+
46+
.PHONY: install
47+
install: dist ## Installs the plugin
48+
cp -r dist/* "$(INSTALL_DIR)"
49+
rm -rf $(INSTALL_DIR)/$(PLUGIN_ID)
50+
@echo "Installed plugin to $(INSTALL_DIR)"
51+
52+
$(OPENGAMEPAD_UI_BASE):
53+
git clone $(OPENGAMEPAD_UI_REPO) $@
54+
55+
$(PLUGINS_DIR)/$(PLUGIN_ID): $(OPENGAMEPAD_UI_BASE)
56+
if ! [ -L $(PLUGINS_DIR)/$(PLUGIN_ID) ]; then ln -s $(PWD) $(PLUGINS_DIR)/$(PLUGIN_ID); fi
57+
58+
.PHONY: export_preset
59+
export_preset: $(OPENGAMEPAD_UI_BASE) ## Configure plugin export preset
60+
$(eval LAST_PRESET=$(shell grep -oEi '^\[preset\.([0-9]+)]' $(EXPORT_PRESETS) | tail -n 1))
61+
$(eval LAST_PRESET_NUM=$(shell echo "$(LAST_PRESET)" | grep -oE '([0-9]+)'))
62+
$(eval PRESET_NUM=$(shell echo "$(LAST_PRESET_NUM)+1" | bc))
63+
@if grep 'name="$(PLUGIN_NAME)"' $(EXPORT_PRESETS) > /dev/null; then \
64+
echo "Export preset already configured"; \
65+
else \
66+
echo "Preset not configured"; \
67+
sed 's/PRESET_NUM/$(PRESET_NUM)/g; s/PLUGIN_NAME/$(PLUGIN_NAME)/g; s/PLUGIN_ID/$(PLUGIN_ID)/g' export_presets.cfg >> $(EXPORT_PRESETS); \
68+
fi

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# OpenGamepadUI Plugin Template
2+
3+
This repository contains a reference template for creating a plugin for
4+
[OpenGamepadUI](https://github.com/ShadowBlip/OpenGamepadUI).
5+
6+
## Requirements
7+
8+
You will need to install the dependencies for OpenGamepadUI listed
9+
[here](https://github.com/ShadowBlip/OpenGamepadUI#requirements).
10+
11+
## Usage
12+
13+
This repository contains the basic files you need to write your own plugin.
14+
It includes a [Makefile](Makefile) which you can use to build and package your
15+
plugin. For help using the Makefile, run:
16+
17+
```bash
18+
make help
19+
```
20+
21+
Use the following steps to get started:
22+
23+
1. Fork this repository and clone your repository locally
24+
25+
2. Clone the [OpenGamepadUI](https://github.com/ShadowBlip/OpenGamepadUI) repository next to your plugin folder. It should look something like this:
26+
27+
```bash
28+
$ ls
29+
OpenGamepadUI
30+
OpenGamepadUI-plugin-template
31+
```
32+
33+
3. Edit `plugin.json` in your plugin repository and fill our your plugin details
34+
35+
4. Run `make build` from your plugin repository to symlink your plugin inside the OpenGamepadUI project directory
36+
37+
5. Open the OpenGamepadUI project in the Godot editor
38+
39+
Once you have completed these steps, you can use the Godot editor to write your
40+
plugin.
41+
42+
You can build and install this plugin with:
43+
44+
```bash
45+
make install
46+
```
47+
48+
For more in-depth documentation on how to write plugins, refer to the
49+
[Plugin Development Guide](https://github.com/ShadowBlip/OpenGamepadUI/blob/main/docs/PLUGINS.md)
50+
51+
## Distribution
52+
53+
You can distribute your plugin by building a plugin package with:
54+
55+
```bash
56+
make dist
57+
```
58+
59+
This will create a zip file under the `dist` directory.
60+
61+
To have your plugin be considered for inclusion in the OpenGamepadUI plugin store,
62+
create a pull request to the [OpenGamepadUI-plugins](https://github.com/ShadowBlip/OpenGamepadUI-plugins)
63+
repository with an entry for your plugin to have your plugin listed in the
64+
plugin store.

assets/.gitkeep

Whitespace-only changes.

core/.gitkeep

Whitespace-only changes.

export_presets.cfg

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
[preset.PRESET_NUM]
3+
4+
name="PLUGIN_NAME"
5+
platform="Linux/X11"
6+
runnable=false
7+
dedicated_server=false
8+
custom_features=""
9+
export_filter="resources"
10+
export_files=PackedStringArray()
11+
include_filter="plugins/PLUGIN_ID/*"
12+
exclude_filter="addons/*"
13+
export_path="build/PLUGIN_ID.x86_64"
14+
encryption_include_filters=""
15+
encryption_exclude_filters=""
16+
encrypt_pck=false
17+
encrypt_directory=false
18+
script_encryption_key=""
19+
20+
[preset.PRESET_NUM.options]
21+
22+
custom_template/debug=""
23+
custom_template/release=""
24+
debug/export_console_script=1
25+
binary_format/embed_pck=false
26+
texture_format/bptc=true
27+
texture_format/s3tc=true
28+
texture_format/etc=false
29+
texture_format/etc2=false
30+
binary_format/architecture="x86_64"
31+
ssh_remote_deploy/enabled=false
32+
ssh_remote_deploy/host="user@host_ip"
33+
ssh_remote_deploy/port="22"
34+
ssh_remote_deploy/extra_args_ssh=""
35+
ssh_remote_deploy/extra_args_scp=""
36+
ssh_remote_deploy/run_script="#!/usr/bin/env bash
37+
export DISPLAY=:0
38+
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
39+
\"{temp_dir}/{exe_name}\" {cmd_args}"
40+
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
41+
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
42+
rm -rf \"{temp_dir}\""

plugin.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extends Plugin
2+
3+
# Called when the node enters the scene tree for the first time.
4+
func _ready() -> void:
5+
logger = Log.get_logger("TemplatePlugin", Log.LEVEL.DEBUG)
6+
logger.info("Template plugin loaded")

plugin.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"plugin.id": "template",
3+
"plugin.name": "Template Plugin",
4+
"plugin.version": "1.0.0",
5+
"plugin.min-api-version": "1.0.0",
6+
"plugin.link": "",
7+
"plugin.source": "",
8+
"plugin.description": "",
9+
"store.tags": [],
10+
"store.images": [],
11+
"author.name": "First Last",
12+
"author.email": "[email protected]",
13+
"entrypoint": "plugin.gd"
14+
}

0 commit comments

Comments
 (0)