Skip to content

Commit

Permalink
📖Update Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark2000 committed Dec 30, 2022
1 parent 87ddd1c commit 4a28dca
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 116 deletions.
149 changes: 111 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Panku Console ![](https://badgen.net/badge/Godot%20Compatible/4.0Beta7%2B/cyan) ![](https://badgen.net/github/release/Ark2000/PankuConsole) ![](https://badgen.net/github/license/Ark2000/PankuConsole)
# Panku Console ![](https://badgen.net/badge/Godot%20Compatible/4.0Beta10%2B/cyan) ![](https://badgen.net/github/release/Ark2000/PankuConsole) ![](https://badgen.net/github/license/Ark2000/PankuConsole)

![zr5DqU.md.png](https://s1.ax1x.com/2022/12/04/zr5DqU.md.png)

A [Godot 4](https://godotengine.org/) Plugin. Provide a runtime console so your can run any script expression in your game!
[![pSpJEjK.png](https://s1.ax1x.com/2022/12/30/pSpJEjK.png)](https://imgse.com/i/pSpJEjK)

A [Godot 4](https://godotengine.org/) Plugin. Panku Conosle is a set of tools to help you troubleshoot and iterate on game ideas on your target platform in realtime. On-device access to the GDScript REPL console and its many tools in any game build allows you to investigate bugs without deploying a debug build specific to your machine.

# ✨Features

Expand All @@ -13,19 +12,20 @@ A [Godot 4](https://godotengine.org/) Plugin. Provide a runtime console so your

✅ Simple but reliable notification system. Send notifications whenerver you want.

✅ Floating widgets system. Monitor variables or performance, add buttons and save them in runtime .
✅ Create expression monitors and buttons widgets in one click.

✅ Exported properties panel can help you find the perfect parameters for gameplay features in realtime.

✅ Auto-complete your expression using `tab` with help information extracted from your code.

✅ Navigate throught submit histories using `up`/`down`.

✅ You can always press F1 and search `PankuConsole` in your editor to get the coding documentation.

<img src="https://github.com/Ark2000/Files/blob/main/F2.gif?raw=true" width = "640" height = "360" alt="f2"/>
✅ A lot of useful expressions are prefined to suite your need.

![f1](https://github.com/Ark2000/Files/blob/main/F1.gif?raw=true)

![f3](https://github.com/Ark2000/Files/blob/main/F3.gif?raw=true)
[![pSpJ6DU.png](https://s1.ax1x.com/2022/12/30/pSpJ6DU.png)](https://imgse.com/i/pSpJ6DU)
*Plugin screenshot. The demo game here is OpenTTD.*

# 📦Installation

Expand All @@ -35,50 +35,123 @@ A [Godot 4](https://godotengine.org/) Plugin. Provide a runtime console so your

For more detailed information, please visit [Installing plugins](https://docs.godotengine.org/en/latest/tutorials/plugins/editor/installing_plugins.html)

# 🤔How does it work?
# 🌊Getting Started

Quick setup and easy configuration were important goals when designing Panku Console.

After the installation, Panku Console will be accessible in all scenes of your project automatically.

## Opening the REPL Window

Panku Console is currently only designed for platforms with a keyboard and a mouse. The plugin will define an input action called "toggle_console" which is corresponding to the `~` key. You can change the way to call the REPL window later.

All Panku windows you created will be remembered so you don't have to open the windows again and again.

## What can you do in the default REPL environment?

Panku REPL can only execute GDScript expressions. An expression can be made of any arithmetic operation, built-in math function call, method call of environment objects, or built-in type construction call. For more information, please visit [Godot Docs](https://docs.godotengine.org/en/stable/tutorials/scripting/evaluating_expressions.html)

Here are some example expressions.

```gdscript
#A simple math expression with built-in math function calls that you can find in @GlobalScope and @GDScript
round(sin(2*PI+1.7*4.2+0.6))
> 1
#Below are some predefined environment scripts. You can try to add some properties in <repl_base_instance.gd> to play around.
#Call a get method defined in <repl_base_instance.gd>
help
> ...
#Call a method defined in <repl_console_env.gd>
console.notify("[color=red]Hello![/color]")
> <null>
#Call a get method defined in <repl_engine_env.gd>
engine.snap_screenshot
> <null>
#Call a method defined in <repl_widgets_env.gd>
widgets.profiler
> <null>
#Invalid expression, since assignment is not allowed.
player.scale = Vector2(2, 2)
> Expected '='
#But you can use set method instead.
player.set("scale", Vector2(2, 2))
> <null>
```

By the way, the REPL input box provides auto completion and histories functionalities which means you only need to type `snap` and then press `TAB` to run `engine.snap_screenshot`.

[![pSpg26S.png](https://s1.ax1x.com/2022/12/30/pSpg26S.png)](https://imgse.com/i/pSpg26S)

## How to add your own objects in the REPL environment?

Panku Console provides an API to register objects in the REPL environment, so the process should be very easy.

Suppose the code below is your player script.

```gdscript
extends Node2D
func _ready():
Console.register_env("player", self)
#the help info is optional
const _HELP_hello = "sample function"
func hello(name):
return "hello! %s" % name
#...
```

And now you can type `player.hello("Jason")` in the REPL to call the function you have just defined.


## How to monitor an expression or add an expression button?

1. Enable this plugin, it will add an autoload singleton which named `Panku` in your project.
2. Run any scene, press `~` key, and the console window will pop up. (The key can be changed in the script)
3. The console window explanation:
The monitor widgets defined in `repl_widgets_env.gd` are very useful if you are instersted in some expressions.

[![z1NQGq.png](https://s1.ax1x.com/2022/11/22/z1NQGq.png)](https://imgse.com/i/z1NQGq)
For example, this predefined expression `engine.performance_info` will return a string shows the current performance information. It's very simple to monitor this expression, just type the expression you want to keep watching in the **input box** and then click the **hammer icon** right next to the input box and select `Make Monitor`, done! The monitor widget will pop up at the top left corner, and you may want to adjust its size to fit the output.

1. The title, drag this to move the window around.
2. Exit button, click to close the window.
3. Env options, use `Panku.register_env()` to add more envs.
4. Input field, press enter to submit, up/down to navigate history input.
5. Resize button, drag this to resize the window.
That's the monitor part. sometimes you want to create a button that execute an expression such as summon an enemy or recharge the health so you don't have to type it tediously, then you can create an expression button widget.

4. Try to type 'abs(cos(PI))', you will see the result `1`.
The process is exactly the same as creating a monitor widget, the only difference is that you have to select `Make Button` option.

5. Now, try to type `help` and you will get some basic hints.
In fact, the two widgets are the same thing, the only difference is their's update frenquency which you can change later in the widget settings tab.

[![z1DXHf.png](https://s1.ax1x.com/2022/11/22/z1DXHf.png)](https://imgse.com/i/z1DXHf)
## How to create an export properties panel?

How is this implemented? Well, it's EXTREMELY easy, just define a variable or constant like this in the `default_env.gd`, more details will be explained in the next step.
```gdscript
const _HELP_help = "this string will be used as help info in auto-completion"
var help = "available methods: say_hi(), enable_in_game_logs(bool), cls()"
```
6. The core execution procedure is implemented by `Expression` which is a class that stores an expression you can execute.
It can be incredible useful to be able to modify gameplay parameters while on the target device. The export properties panel enables this by scanning for export properties.

For example, you can add `Panku.regiter_env("player", self)` in the `_ready()` function of your player script.
Once it's done, suppose there is a variable called `hp` in your player script, you can type `hp` (The left option button should be `player`) in the console, then you will get the actual value of player's hp.
What's more, you can type `set("hp", 100)` to change the value(Note that you can't use `hp=100` since this is not a valid expression).
The target object should be registered in the REPL environemnt.

For more information about what is `Expression`, please visit [Evaluating expressions](https://docs.godotengine.org/en/stable/tutorials/scripting/evaluating_expressions.html)
As the picture below depicts, valid objects will be listed in the tool menu and you can select the target object to create its export properties panel.

7. Check `panku.gd` or type `F1` and search `PankuConsole` to see what you can do with the global singleton `Console`
[![pSpWlwQ.png](https://s1.ax1x.com/2022/12/30/pSpWlwQ.png)](https://imgse.com/i/pSpWlwQ)

At last, please pay attention that while this plugin is powerful, it's not ready for players since `Expression` is unsafe and exposes lots of internal structure.
This is the export properties defined in player script.

A safer command system is being actively developed which can be used by the players, see the Roadmap part below.
```gdscript
@export var simple_float_value:float = 123.0
@export_range(10, 30) var int_range:int = 1
@export var simple_int_value:int = 456
@export_range(400, 700, 0.1) var speed:float = 400.0
@export var bool1:bool = false
@export var player_name:String = "player"
@export var player_color:Color = Color.WHITE
@export_enum("Warrior", "Magician", "Thief") var character_class=0
```

# 🗺Roadmap
And the result export properties panel will be like this.

We're planning to add more features to this plugin in the future, stay tuned!
[![pSpWwmF.png](https://s1.ax1x.com/2022/12/30/pSpWwmF.png)](https://imgse.com/i/pSpWwmF)

Roadmap: [Panku Console Roadmap](https://github.com/users/Ark2000/projects/1)
**Note**: Not all export variables are supported now. And if an export property's value is changed in code anywhere outside of the GUI, the new value won't be reflected there. Use monitor widget to listen values.

# 🏗Contrubuting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ script = ExtResource("1_3r4hk")

[node name="R" type="RichTextLabel" parent="."]
layout_mode = 2
offset_left = 8.0
offset_top = 8.0
offset_right = 357.0
offset_bottom = 349.0
bbcode_enabled = true
scroll_following = true
12 changes: 6 additions & 6 deletions addons/panku_console/components/resident_logs/log_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func _ready():
OS.shell_open(str(meta))
)

await get_tree().process_frame
var tween = get_tree().create_tween()
modulate.a = 0.0
position.x -= size.x / 2
tween.tween_property(self, "position:x", size.x / 2, 0.2).as_relative().set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
tween.set_parallel().tween_property(self, "modulate:a", 1.0, 0.2).as_relative().set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
# await get_tree().process_frame
# var tween = get_tree().create_tween()
# modulate.a = 0.0
# position.x -= size.x / 2
# tween.tween_property(self, "position:x", size.x / 2, 0.2).as_relative().set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
# tween.set_parallel().tween_property(self, "modulate:a", 1.0, 0.2).as_relative().set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
21 changes: 6 additions & 15 deletions addons/panku_console/components/resident_logs/log_item.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,27 @@ metadata/amount_label = NodePath("Amount/MarginContainer/Label")
metadata/amount_panel = NodePath("Amount")

[node name="Content" type="PanelContainer" parent="."]
offset_right = 290.0
offset_bottom = 26.0
layout_mode = 2
size_flags_horizontal = 3

[node name="MarginContainer" type="MarginContainer" parent="Content"]
offset_right = 290.0
offset_bottom = 26.0
layout_mode = 2
theme_override_constants/margin_left = 8

[node name="RichTextLabel" type="RichTextLabel" parent="Content/MarginContainer"]
offset_left = 8.0
offset_right = 290.0
offset_bottom = 26.0
layout_mode = 2
bbcode_enabled = true
fit_content_height = true

[node name="Amount" type="PanelContainer" parent="."]
offset_left = 294.0
offset_right = 320.0
offset_bottom = 26.0
layout_mode = 2

[node name="MarginContainer" type="MarginContainer" parent="Amount"]
offset_right = 26.0
offset_bottom = 26.0
layout_mode = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_right = 4

[node name="Label" type="Label" parent="Amount/MarginContainer"]
offset_left = 4.0
offset_right = 22.0
offset_bottom = 26.0
layout_mode = 2
text = "x6"
metadata/amount = 1
17 changes: 10 additions & 7 deletions addons/panku_console/components/widgets2/monitor_widget.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ custom_minimum_size = Vector2(0, 1)

[node name="RichTextLabel" type="RichTextLabel" parent="Body/Content" index="0"]
layout_mode = 1
anchors_preset = 15
anchors_preset = -1
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 8.0
offset_top = 8.0
offset_right = -8.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/normal_font_size = 14
theme_override_font_sizes/bold_font_size = 14
theme_override_font_sizes/italics_font_size = 14
theme_override_font_sizes/bold_italics_font_size = 14
theme_override_font_sizes/mono_font_size = 14
text = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
theme_override_font_sizes/normal_font_size = 12
theme_override_font_sizes/bold_font_size = 12
theme_override_font_sizes/italics_font_size = 12
theme_override_font_sizes/bold_italics_font_size = 12
theme_override_font_sizes/mono_font_size = 12
text = "NO OUTPUT"
scroll_active = false

[node name="SettingsUI" type="ColorRect" parent="Body/Content" index="1"]
Expand Down
5 changes: 3 additions & 2 deletions addons/panku_console/console.gd
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func get_available_export_objs() -> Array:
return result

func show_intro():
output("[center][img=96]res://addons/panku_console/logo.svg[/img][/center]")
output("[b][color=burlywood][ Panku Console ][/color][/b]")
output("[color=burlywood][b][color=burlywood]Version 1.2.31[/color][/b][/color]")
output("[color=burlywood][b]Check [color=green]repl_console_env.gd[/color] or simply type [color=green]help[/color] to see what you can do now![/b][/color]")
Expand All @@ -151,6 +152,8 @@ func _input(_e):
func _ready():
assert(get_tree().current_scene != self, "Do not run this directly")

show_intro()

pause_when_active = ProjectSettings.get("panku/pause_when_active")
toggle_console_action = ProjectSettings.get("panku/toggle_console_action")

Expand Down Expand Up @@ -198,8 +201,6 @@ func _ready():
_console_window.size = cfg.repl.size

PankuConfig.set_config(cfg)

show_intro()

func _notification(what):
#quit event
Expand Down
22 changes: 22 additions & 0 deletions addons/panku_console/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions addons/panku_console/logo.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://rkxm4c3bbf34"
path="res://.godot/imported/logo.svg-5c6f042742ccac523c072414b9eb3caf.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/panku_console/logo.svg"
dest_files=["res://.godot/imported/logo.svg-5c6f042742ccac523c072414b9eb3caf.ctex"]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
4 changes: 2 additions & 2 deletions addons/panku_console/plugin.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[plugin]

name="PankuConsole"
description="Godot 4 Plugin. Provide a runtime console so your can just ran any script expression in your game!"
description="A Godot 4 Plugin. Panku Conosle is a set of tools to help you troubleshoot and iterate on game ideas on your target platform in realtime. On-device access to the GDScript REPL console and its many tools in any game build allows you to investigate bugs without deploying a debug build specific to your machine."
author="Feiyue Wu"
version="1.1.23"
version="1.2.32"
script="plugin.gd"
Loading

0 comments on commit 4a28dca

Please sign in to comment.