Skip to content

Commit

Permalink
1. Simplified project structure
Browse files Browse the repository at this point in the history
2. Removed deprecated methods
  • Loading branch information
quentincaffeino committed Jul 9, 2021
1 parent 3b889d4 commit 5eec107
Show file tree
Hide file tree
Showing 220 changed files with 10,850 additions and 22,035 deletions.
11 changes: 2 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/godot/addons/gut export-ignore
/godot/assets export-ignore
/godot/demo export-ignore
/godot/export_presets.cfg export-ignore
/godot/.gutconfig.json export-ignore
/godot/.import export-ignore
/godot/project.godot export-ignore
/godot/reference.json export-ignore
/godot/test export-ignore
/addons/gut export-ignore
/demo export-ignore
/LICENSE.md export-ignore
/logs export-ignore
/Makefile export-ignore
Expand Down
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ GDSCRIPT_DOCS_MAKER_BIN_NAME="godot_generate_reference"
GDSCRIPT_DOCS_MAKER="${PWD}/gdscript-docs-maker/generate_reference"
GDSCRIPT_DOCS_MAKER_PATH=$(shell dirname "${GDSCRIPT_DOCS_MAKER}")

PROJECT_PATH="${PWD}/godot"
ADDON_PATH="${PROJECT_PATH}/addons/quentincaffeino-console"
PROJECT_DEMO_PATH="${PWD}/demo"
ADDON_PATH="${PROJECT_DEMO_PATH}/addons/quentincaffeino/console"
ADDON_DOCS_PATH="${ADDON_PATH}/docs/generated"


.PHONY: run-demo
run-demo:
@(cd "${PROJECT_PATH}" && "${GODOT}" -v)
@(cd "${PROJECT_DEMO_PATH}" && "${GODOT}" -v)

.PHONY: run-demo-editor
run-demo-editor:
@(cd "${PROJECT_PATH}" && "${GODOT}" -v -e)
@(cd "${PROJECT_DEMO_PATH}" && "${GODOT}" -v -e)


.PHONY: generate-docs
generate-docs:
@(cd "${GDSCRIPT_DOCS_MAKER_PATH}" && \
"${GDSCRIPT_DOCS_MAKER}" "${PROJECT_PATH}" -o "${ADDON_DOCS_PATH}")
"${GDSCRIPT_DOCS_MAKER}" "${PROJECT_DEMO_PATH}" -o "${ADDON_DOCS_PATH}")


.PHONY: test
test:
@(cd "${PROJECT_PATH}" && \
"${GODOT}" -s res://addons/gut/gut_cmdln.gd -d)
find addons/quentincaffeino/ -name ".gutconfig.json" -type f -print | xargs -d0 -I{} "${GODOT}" -s addons/gut/gut_cmdln.gd -d --path demo/ -gconfig="res://{}"
66 changes: 29 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,77 @@
# Godot Console

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

![In-game console for Godot Screenshot](assets/screenshot.png)

In-game console for Godot, which could be easily extended with new commands.

- [Godot Console](#godot-console)
- [Features](#features)
- [Installation](#installation)
- [Via GIT (preferred)](#via-git-preferred)
- [Via Editor AssetLib](#via-editor-assetlib)
- [Example usage](#example-usage)
- [Features:](#features)
- [Installation:](#installation)
- [Via Editor AssetLib:](#via-editor-assetlib)
- [Via GIT:](#via-git)
- [Example usage:](#example-usage)
- [GDScript](#gdscript)
- [C#](#c)
- [Contributors](#contributors-)
- [C](#c)
- [Contributors](#contributors-)
- [License](#license)

## Features:

- Creating custom commands with [add_command](godot/addons/quentincaffeino-console/docs/generated/Console.md#add_command).
- Creating custom commands with [add_command](addons/quentincaffeino/console/docs/generated/Console.md#add_command).

- Autocomplete with `TAB` keyboard key.

- Writing to console using [write](godot/addons/quentincaffeino-console/docs/generated/Console.md#write) and [write_line](godot/addons/quentincaffeino-console/docs/generated/Console.md#write_line) methods.
- Writing to console using [write](addons/quentincaffeino/console/docs/generated/Console.md#write) and [write_line](addons/quentincaffeino/console/docs/generated/Console.md#write_line) methods.
You can also use [BB codes](https://docs.godotengine.org/en/stable/tutorials/gui/bbcode_in_richtextlabel.html#using-bbcode).

(Is also printed to engine output)

- Session command history (using `UP` and `DOWN` keyboard arrows).

- Change the number of stored commands in the history. (Change in `Console.gd` line 30 the current NUMBER to an positive integer value)
`30: var History = preload('Misc/History.gd').new(NUMBER) setget _set_protected`
- Change the number of stored commands in the history. (Change in `Console.gd` line 30 the current NUMBER to an positive integer value)
`29: var History = preload('Misc/History.gd').new(NUMBER) setget _set_readonly`

- [Flexible types](godot/addons/quentincaffeino-console/docs/Type.md):
- [Flexible types](addons/quentincaffeino/console/docs/Type.md):

- [Engine types](godot/addons/quentincaffeino-console/docs/Type.md#engine-types)
- [Extra types](godot/addons/quentincaffeino-console/docs/Type.md#extra-types)
- [Custom types](godot/addons/quentincaffeino-console/docs/Type.md#creating-custom-types)
- [Engine types](addons/quentincaffeino/console/docs/Type.md#engine-types)
- [Extra types](addons/quentincaffeino/console/docs/Type.md#extra-types)
- [Custom types](addons/quentincaffeino/console/docs/Type.md#creating-custom-types)

- [FuncRef](https://docs.godotengine.org/en/stable/classes/class_funcref.html) support with Godot >=3.2 (can be used as a command target).

## Installation:

### Via GIT (preferred):
### Via Editor AssetLib:

1. Open AssetLib.
2. Search for Console, category is Scripts; Open it and click Donwload and then Install.
3. Click install. Package installer will copy filestructure as-is so you will have this directories in your project: `addons/quentincaffeino/*`.
4. Open `Project > Project Settings > Plugins`, search for `quentincaffeino-console` and check the Enable checkbox.
5. You can activate the console with <kbd>\`</kbd> while running your game ([can be changed](https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#inputmap), see `quentincaffeino_console_toggle` action).

### Via GIT:

1. Clone this project or download latest [release](https://github.com/quentincaffeino/godot-console/archive/master.zip).
2. Copy `./godot/addons/quentincaffeino-console` into your projects `addons` folder.
2. Copy `./addons/quentincaffeino` into your projects `addons` folder.

So you will have this structure:

```
res://
├── addons
│   ├── quentincaffeino-console
│   ├── quentincaffeino
│   ├── ...
```

3. Open `Project > Project Settings > Plugins`, search for `quentincaffeino-console` and check the Enable checkbox.
4. You can activate the console with `` ` `` while running your game ([can be changed](https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#inputmap), see `quentincaffeino_console_toggle` action).

### Via Editor AssetLib:

1. Open AssetLib.
2. Search for Console, category is Scripts; Open it and click Donwload and then Install.
3. Click install. Package installer will copy filestructure as-is so you will have this directories in your project: `godot/addons/quentincaffeino-console`.
4. Create `addons` folder if you haven't already and move `quentincaffeino-console` there so you will have this structure:

```
res://
├── addons
│   ├── quentincaffeino-console
│   ├── ...
```

5. Open `Project > Project Settings > Plugins`, search for `quentincaffeino-console` and check the Enable checkbox.
6. You can activate the console with `` ` `` while running your game ([can be changed](https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#inputmap), see `quentincaffeino_console_toggle` action).
4. You can activate the console with <kbd>\`</kbd> while running your game ([can be changed](https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#inputmap), see `quentincaffeino_console_toggle` action).

## Example usage:

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
130 changes: 130 additions & 0 deletions addons/gut/comparator.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
var _utils = load('res://addons/gut/utils.gd').get_instance()
var _strutils = _utils.Strutils.new()
var _max_length = 100
var _should_compare_int_to_float = true

const MISSING = '|__missing__gut__compare__value__|'
const DICTIONARY_DISCLAIMER = 'Dictionaries are compared-by-ref. See assert_eq in wiki.'

func _cannot_comapre_text(v1, v2):
return str('Cannot compare ', _strutils.types[typeof(v1)], ' with ',
_strutils.types[typeof(v2)], '.')

func _make_missing_string(text):
return '<missing ' + text + '>'

func _create_missing_result(v1, v2, text):
var to_return = null
var v1_str = format_value(v1)
var v2_str = format_value(v2)

if(typeof(v1) == TYPE_STRING and v1 == MISSING):
v1_str = _make_missing_string(text)
to_return = _utils.CompareResult.new()
elif(typeof(v2) == TYPE_STRING and v2 == MISSING):
v2_str = _make_missing_string(text)
to_return = _utils.CompareResult.new()

if(to_return != null):
to_return.summary = str(v1_str, ' != ', v2_str)
to_return.are_equal = false

return to_return


func simple(v1, v2, missing_string=''):
var missing_result = _create_missing_result(v1, v2, missing_string)
if(missing_result != null):
return missing_result

var result = _utils.CompareResult.new()
var cmp_str = null
var extra = ''

if(_should_compare_int_to_float and [2, 3].has(typeof(v1)) and [2, 3].has(typeof(v2))):
result.are_equal = v1 == v2

elif(_utils.are_datatypes_same(v1, v2)):
result.are_equal = v1 == v2
if(typeof(v1) == TYPE_DICTIONARY):
if(result.are_equal):
extra = '. Same dictionary ref. '
else:
extra = '. Different dictionary refs. '
extra += DICTIONARY_DISCLAIMER

if(typeof(v1) == TYPE_ARRAY):
var array_result = _utils.DiffTool.new(v1, v2, _utils.DIFF.SHALLOW)
result.summary = array_result.get_short_summary()
if(!array_result.are_equal()):
extra = ".\n" + array_result.get_short_summary()

else:
cmp_str = '!='
result.are_equal = false
extra = str('. ', _cannot_comapre_text(v1, v2))

cmp_str = get_compare_symbol(result.are_equal)
if(typeof(v1) != TYPE_ARRAY):
result.summary = str(format_value(v1), ' ', cmp_str, ' ', format_value(v2), extra)

return result


func shallow(v1, v2):
var result = null

if(_utils.are_datatypes_same(v1, v2)):
if(typeof(v1) in [TYPE_ARRAY, TYPE_DICTIONARY]):
result = _utils.DiffTool.new(v1, v2, _utils.DIFF.SHALLOW)
else:
result = simple(v1, v2)
else:
result = simple(v1, v2)

return result


func deep(v1, v2):
var result = null

if(_utils.are_datatypes_same(v1, v2)):
if(typeof(v1) in [TYPE_ARRAY, TYPE_DICTIONARY]):
result = _utils.DiffTool.new(v1, v2, _utils.DIFF.DEEP)
else:
result = simple(v1, v2)
else:
result = simple(v1, v2)

return result


func format_value(val, max_val_length=_max_length):
return _strutils.truncate_string(_strutils.type2str(val), max_val_length)


func compare(v1, v2, diff_type=_utils.DIFF.SIMPLE):
var result = null
if(diff_type == _utils.DIFF.SIMPLE):
result = simple(v1, v2)
elif(diff_type == _utils.DIFF.SHALLOW):
result = shallow(v1, v2)
elif(diff_type == _utils.DIFF.DEEP):
result = deep(v1, v2)

return result


func get_should_compare_int_to_float():
return _should_compare_int_to_float


func set_should_compare_int_to_float(should_compare_int_float):
_should_compare_int_to_float = should_compare_int_float


func get_compare_symbol(is_equal):
if(is_equal):
return '=='
else:
return '!='
47 changes: 47 additions & 0 deletions addons/gut/compare_result.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var are_equal = null setget set_are_equal, get_are_equal
var summary = null setget set_summary, get_summary
var max_differences = 30 setget set_max_differences, get_max_differences
var differences = {} setget set_differences, get_differences

func _block_set(which, val):
push_error(str('cannot set ', which, ', value [', val, '] ignored.'))

func _to_string():
return str(get_summary()) # could be null, gotta str it.

func get_are_equal():
return are_equal

func set_are_equal(r_eq):
are_equal = r_eq

func get_summary():
return summary

func set_summary(smry):
summary = smry

func get_total_count():
pass

func get_different_count():
pass

func get_short_summary():
return summary

func get_max_differences():
return max_differences

func set_max_differences(max_diff):
max_differences = max_diff

func get_differences():
return differences

func set_differences(diffs):
_block_set('differences', diffs)

func get_brackets():
return null

Loading

0 comments on commit 5eec107

Please sign in to comment.