Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI #9

Draft
wants to merge 93 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
281738c
First bits of framework for CLI console.
will-ca Oct 30, 2021
019f6bb
More fleshed out backend API, autocomplete API, command history, pers…
will-ca Oct 30, 2021
c617486
Add management UI for simultaneous running CLI backends, and example …
will-ca Oct 30, 2021
4ed1083
Fix translation/substitution in CLI printing. Make most demo CLI comm…
will-ca Oct 31, 2021
03283e9
Try to fix CLI screen key binding persistence with SomeTroglodyte's s…
will-ca Oct 31, 2021
2e0ca17
Make last demo command functional.
will-ca Nov 1, 2021
d045c65
Property path parsing/introspecting from strings.
will-ca Nov 1, 2021
8182a99
More on path resolution/inspection. Better autocomplete.
will-ca Nov 1, 2021
37f6184
Implement setting arbitrary properties by path and value.
will-ca Nov 1, 2021
c8bb5ae
Rename backend-y CLI stuff to "Scripting" instead of "Console".
will-ca Nov 1, 2021
b49bec6
Depend on Enums more for organizing backend types.
will-ca Nov 2, 2021
02d4902
Make `ScriptingScope` properties nullable.
will-ca Nov 2, 2021
acff07d
Make ConsoleScreen and ScriptingState persistent per UncivGame. Enabl…
will-ca Nov 2, 2021
4d7c602
Remake `ConsoleScreen()` but keep `ScriptingState()` on window resize.
will-ca Nov 2, 2021
405c66b
Include Python IPC experiment.
will-ca Nov 2, 2021
1a2c5ea
Add parsing reflective console backend.
will-ca Nov 2, 2021
5abeacd
Comments, apparently.
will-ca Nov 3, 2021
82c8075
Options menu to enable console, defaulting to OFF.
will-ca Nov 3, 2021
55dac3a
Add system Python backend.
will-ca Nov 3, 2021
4cf48a6
Added `SubprocessReplManager` utility class and `SubprocessScriptingB…
will-ca Nov 3, 2021
7511a92
Split up classes. Prepare to add two-way IPC or different external in…
will-ca Nov 4, 2021
e036dbb
Copy temporary file trees for each backend instance. Enable JS and Lu…
will-ca Nov 5, 2021
ac42cf9
Implement reflective function calls.
will-ca Nov 5, 2021
f6f05c5
Implement IPC protocol for existing functionality.
will-ca Nov 7, 2021
3c268d8
Python bindings for accessing, indexing, assigning, calling, and perf…
will-ca Nov 7, 2021
17c74fc
Protocol changes. Python iteration over Kotlin objects.
will-ca Nov 8, 2021
4e427a6
Fix ConcurrentModificationException() from ScriptingObjectIndex's .cl…
will-ca Nov 8, 2021
506e1fa
Magic methods for Python.
will-ca Nov 8, 2021
b9e46a9
Rewrite and greatly improve Python autocomplete. Various cleanup and …
will-ca Nov 11, 2021
fdc1712
More cleanup.
will-ca Nov 11, 2021
13ff214
Cleanup. Docs. Key assignments. Script-side memory management for Kot…
will-ca Nov 11, 2021
ad6770d
More docs, fixes, finishing features, cleanup.
will-ca Nov 12, 2021
d6642e9
Organized Python modules, made API available via `import`.
will-ca Nov 12, 2021
b466f77
Add raw string REPL back in to re-enable JS and Lua backends.
will-ca Nov 12, 2021
1993c7f
Convert existing doc comments to valid KDoc. Also fix QJS eating CPU …
will-ca Nov 13, 2021
7d227ef
Move Python doc into Markdown file too.
will-ca Nov 13, 2021
c9b0b6a
Cool, Table of Contents in Markdown.
will-ca Nov 13, 2021
d5c8d51
Small doc and Python fixes.
will-ca Nov 13, 2021
d614eaf
Cleanup and docs. Python examples. Separate Python `unciv` module and…
will-ca Nov 13, 2021
60c9a64
In-place Python operators. Docs.
will-ca Nov 14, 2021
3b3f3a4
Mostly random notes/placeholders.
will-ca Nov 16, 2021
d4ac1d1
KDocs for most things.
will-ca Nov 17, 2021
210a293
Interface/extensions for opening ConsoleScreen. ConsoleScreen in Map …
will-ca Nov 19, 2021
9af0976
Rename "CameraStageBaseScreen" to "BaseScreen" in ConsoleScreen classes.
will-ca Nov 19, 2021
e01b597
Remove code disabled in last commit.
will-ca Nov 19, 2021
c31edfb
Remove resolved TODOs.
will-ca Nov 19, 2021
04315d7
Multiple dispatch for foreign script calls. Previous behaviour would …
will-ca Nov 22, 2021
b8474be
Cleanup, docs.
will-ca Nov 22, 2021
2ffd5ac
Fix pre-existing memory leak, string-parsing reflective call params. …
will-ca Nov 22, 2021
4c976b8
Docs, examples.
will-ca Nov 23, 2021
4f74dd1
Docs.
will-ca Nov 23, 2021
20c9913
Rixed missprerring of rinciple.
will-ca Nov 23, 2021
1612bfa
Docs, diagram.
will-ca Nov 24, 2021
fb15050
Docs, fixes.
will-ca Nov 24, 2021
d28b762
Resolve ambiguous multiple dispatch by type hierarchy. Python testing…
will-ca Nov 26, 2021
0313aa7
Docs?
will-ca Nov 28, 2021
c329a0a
Examples. Docs. Experimenting with fleshing out script-available fact…
will-ca Nov 30, 2021
5f34138
Generalize multiple method dispatch to not automatically add receiver…
will-ca Dec 1, 2021
1cb4e3c
Comments, notes, style. Add many TODOs.
will-ca Dec 7, 2021
190f3d3
Reorganize API helpers. Plan to completely change binding semantics.
will-ca Dec 7, 2021
9c08e39
Switch to binding by reference instead of binding by path. Old model …
will-ca Dec 8, 2021
fe5a3cd
Close 20-something TODOs.
will-ca Dec 8, 2021
018c3db
Implement WeakIdentityMap
will-ca Dec 9, 2021
69399fe
Implement token reuse via weak references to try to fix long-standing…
will-ca Dec 9, 2021
f19c7fb
Stop trying to clean all invalid tokens on every single (de)tokenizat…
will-ca Dec 9, 2021
1ad5bd5
Rebase!
will-ca Dec 9, 2021
0e0eb54
Remove backup files accidentally included in rebase. (Rewrite history…
will-ca Dec 9, 2021
8c426e9
Event popup example.
will-ca Dec 10, 2021
c35d833
Make a lot of things into singletons.
will-ca Dec 10, 2021
6340815
Scripting mutex. Script execution context. Script-to-JVM exception pr…
will-ca Dec 10, 2021
c8d60b4
New parser for Pathcode DSL. Reflective scripting backend tests.
will-ca Dec 10, 2021
decf486
Disable `-XstartOnFirstThread` when not on Mac.
will-ca Dec 11, 2021
6d0f8d6
Scripting OptionsPopup tab. Warning labels and confirmation dialogs. …
will-ca Dec 11, 2021
6ef4984
Lower Gradle RAM limit again.
will-ca Dec 11, 2021
361eabd
Auto-generated atlas and docs.
will-ca Dec 11, 2021
669044e
Update desktop Mac arguments.
will-ca Dec 11, 2021
de2c35b
Kotlin reorganization and Python tests for scripting lock.
will-ca Dec 11, 2021
daff295
Starting layout/prototyping of mod script handler system. (A separate…
will-ca Dec 11, 2021
ae46e3e
Soft-code default Python imports.
will-ca Dec 12, 2021
8fd7ef1
Disable scripting in multiplayer.
will-ca Dec 12, 2021
06575e3
Let shutdown/dispose handlers be registered in UncivGame.
will-ca Dec 12, 2021
04856b8
Delete scripting environment directories on backend termination.
will-ca Dec 12, 2021
2d21675
Add Python shadow module to enable some semblance of emulated script …
will-ca Dec 12, 2021
3beaef3
Tag needed translations as TODOs.
will-ca Dec 12, 2021
531d947
Declarative type specification and runtime type checking for mod scri…
will-ca Dec 12, 2021
0ce52db
Run scripted tests in JUnit tests. Requires OpenGL, system Python, etc.
will-ca Dec 12, 2021
b9e0030
Unit tests for InstanceMethodDispatcher.
will-ca Dec 12, 2021
db3de2b
Tiny change. Println a multiline string instead of escapes in Instanc…
will-ca Dec 12, 2021
e92e7db
Comments, notes, add some TODOs. Runtime collection type parameter de…
will-ca Dec 13, 2021
1ee62be
Implement script handlers/mod script execution. Handler definition th…
will-ca Dec 14, 2021
627beb3
Comments/notes, examples. Bash-autogeneration handler definition boil…
will-ca Dec 20, 2021
e0f0fe3
Rewrite a lot of history. Purge the following files from branch diver…
will-ca Dec 21, 2021
241f89e
Notes, comments.
will-ca Jan 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ Thumbs.db
!/ios-moe/xcode/*.xcodeproj/xcshareddata
!/ios-moe/xcode/*.xcodeproj/project.pbxproj
/ios-moe/xcode/native/
SaveFiles/
android/android-release.apk
android/assets/GameSettings.json
android/release/output.json
Expand All @@ -142,3 +141,17 @@ android/assets/music/

# Visual Studio Code
.vscode/

# Unciv
maps/
mods/
SaveFiles/
SaveFiles
GameSettings.json

# Python
*.pyc
__pycache__

# Geany
.geany
Binary file added android/Images/OtherIcons/Code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/Images/OtherIcons/Script.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions android/assets/jsons/Civ V - Gods & Kings/Terrains.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
"uniques": ["Nullifies all other stats this tile provides", "Doesn't generate naturally"],
// For map editor only - the generator won't place it without code or enabling uniques
// If the map generator is ever updated to always take these into account, it should also take the "Doesn't generate naturally" unique into account
"occursOn": ["Grassland","Plains","Desert","Tundra","Snow","Forest","Jungle","Hill","Flood plains","Marsh","Oasis"]
"occursOn": ["Grassland","Plains","Desert","Tundra","Snow","Forest","Jungle","Hill","Flood plains","Marsh","Oasis"],
"defenceBonus": -0.15
},
{
Expand Down Expand Up @@ -490,7 +490,7 @@
"impassable": true,
"unbuildable": true,
"weight": 10
},
}//,
/*
// BNW wonders
{
Expand Down
4 changes: 2 additions & 2 deletions android/assets/jsons/Civ V - Vanilla/Terrains.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
"uniques": ["Nullifies all other stats this tile provides", "Doesn't generate naturally"],
// For map editor only - the generator won't place it without code or enabling uniques
// If the map generator is ever updated to always take these into account, it should also take the "Doesn't generate naturally" unique into account
"occursOn": ["Grassland","Plains","Desert","Tundra","Snow","Forest","Jungle","Hill","Flood plains","Marsh","Oasis"]
"occursOn": ["Grassland","Plains","Desert","Tundra","Snow","Forest","Jungle","Hill","Flood plains","Marsh","Oasis"],
"defenceBonus": -0.15
},
{
Expand Down Expand Up @@ -490,7 +490,7 @@
"impassable": true,
"unbuildable": true,
"weight": 10
},
}//,
/*
// BNW wonders
{
Expand Down
1 change: 1 addition & 0 deletions android/assets/scripting/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright 2021 will-ca. All rights reserved (for now).
61 changes: 61 additions & 0 deletions android/assets/scripting/ScriptingEngineConstants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{ // Internal directories can't be identified, traversed, or copied on Desktop because all assets are indistinguishable on the classpath or something. So manually list out all files that are part of each engine's runtime environment instead.
engines: {
python: {
files: [
unciv_lib/
unciv_lib/__init__.py
unciv_lib/api.py
unciv_lib/autocompletion.py
unciv_lib/ipc.py
unciv_lib/shadow.py
unciv_lib/utils.py
unciv_lib/wrapping.py
PythonScripting.md
unciv_pyhelpers.py
main.py
unciv_scripting_examples/
unciv_scripting_examples/__init__.py
unciv_scripting_examples/EndTimes.py
unciv_scripting_examples/EventPopup.py
unciv_scripting_examples/ExternalPipe.py
unciv_scripting_examples/MapEditingMacros.py
unciv_scripting_examples/Merfolk.py
unciv_scripting_examples/PlayerMacros.py
unciv_scripting_examples/ProceduralTechtree.py
unciv_scripting_examples/Tests.py
unciv_scripting_examples/TicTacToe.py
unciv_scripting_examples/Utils.py
unciv_scripting_examples/example_assets/EarthTerrainFantasyHex.jpg
unciv_scripting_examples/example_assets/EarthTerrainRaw.png
unciv_scripting_examples/example_assets/EarthTopography.png
unciv_scripting_examples/example_assets/Elizabeth300
unciv_scripting_examples/example_assets/StarryNight.jpg
unciv_scripting_examples/example_assets/TurboRainbow.png
unciv_scripting_examples/example_assets/WheatField.jpg
]
syntaxHighlightingRegexStack: [
]
}
lua: {
files: [
unciv/
main.lua
]
syntaxHighlightingRegexStack: [
]
}
qjs: {
files: [
unciv/
main.js
]
syntaxHighlightingRegexStack: [
]
}
}

sharedfiles: [
ScriptAPI.json
ScriptAPIConstants.json
]
}
19 changes: 19 additions & 0 deletions android/assets/scripting/enginefiles/lua/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

io.stdout:setvbuf('full')


function motd ()
return "\nRunning ".._VERSION..".\n\nThis backend is HIGHLY EXPERIMENTAL. It does not implement any API bindings yet, and it may not be stable. Use it at your own risk!\n\n"
end


while true do
_in = io.stdin:read()
io.stdout:write("> ".._in.."\n")
_, _out = pcall(load("return ".._in))
if not _ then
_, _out = pcall(load(_in))
end
io.stdout:write((_out or "").."\n")
io.stdout:flush()
end
Loading