feat: made a bunch of changes for a web version

This commit is contained in:
Bram Dingelstad 2021-12-12 13:12:29 +01:00
parent 851b39cd2e
commit 23c00ff325
15 changed files with 312 additions and 100 deletions

View file

@ -116,7 +116,7 @@ func get_nodes():
nodes.append(headers)
# Add +2 to the final line to skip the === from that node
# Add +1 to the final line to skip the === from that node
line_number = Array(source_lines).find('===', line_number) + 1
while line_number < source_lines.size() and source_lines[line_number].empty():

View file

@ -309,10 +309,12 @@ func tokenize_line(line, line_number):
var start_index = indentation
if token_stack.size() > 0 :
while token_stack.front().type == Constants.TokenType.Identifier:
if token_stack.size() > 0:
while token_stack.size() > 0 and token_stack.front().type == Constants.TokenType.Identifier:
token_stack.pop_front()
if token_stack.size() == 0:
return
var start_delimit_token = token_stack.front()
start_index = start_delimit_token.column

View file

@ -247,18 +247,18 @@ class FormatFunctionNode extends ParseNode:
var format_text = ''
var expression_value
func _init(parent:ParseNode, parser, expressionCount:int).(parent, parser):
format_text="["
func _init(parent, parser, expression_count).(parent, parser):
format_text = '['
parser.expect_symbol([Constants.TokenType.FormatFunctionStart])
# FIXME: Add exit condition in case of failure
while parser.tokens.size() > 0 and not parser.next_symbol_is([Constants.TokenType.FormatFunctionEnd]):
if parser.next_symbol_is([Constants.TokenType.Text]):
format_text += parser.expect_symbol().value
if InlineExpression.can_parse(parser):
expression_value = InlineExpression.new(self, parser)
format_text +=" \"{%d}\" " % expressionCount
format_text +=" \"{%d}\" " % expression_count
parser.expect_symbol()
format_text+="]"
@ -346,7 +346,6 @@ class CustomCommand extends ParseNode:
var command_tokens = []
command_tokens.append(parser.expect_symbol())
# FIXME: add exit condition
while parser.tokens.size() > 0 and not parser.next_symbol_is([Constants.TokenType.EndCommand]):
command_tokens.append(parser.expect_symbol())
@ -470,7 +469,6 @@ class Block extends ParseNode:
parser.expect_symbol([Constants.TokenType.Indent])
#keep reading statements until we hit a dedent
# FIXME: find exit condition
while parser.tokens.size() > 0 and not parser.next_symbol_is([Constants.TokenType.Dedent]):
#parse all statements including nested blocks
statements.append(Statement.new(self, parser))

View file

@ -0,0 +1,59 @@
extends Control
var open_callback
func _ready():
if OS.get_name() != 'HTML5':
return queue_free()
open_callback = JavaScript.create_callback(self, 'open')
JavaScript.eval("""
window.glue = {
register: function(callback) {
document.querySelector('html').ondrop = function(event) {
console.log('Dropped something!', arguments)
if (event.dataTransfer.files.length) {
var file = event.dataTransfer.files[0]
var extension = file.name.split('.').pop()
if (['wol', 'yarn'].indexOf(extension) === -1)
return console.error('Dropped file wasn\\'t a .yarn or .wol file')
file.text().then(
function (text) {
callback(text, file.name)
}
)
} else {
console.error('Dropped something that wasn\\'t a file!')
}
}
}
}
""", true)
JavaScript.get_interface('glue').register(open_callback)
var file_menu = get_parent().find_node('Menu').get_node('File').get_popup()
file_menu.remove_item(2) # Save as
file_menu.remove_item(1) # Open
func open(arguments):
var text = arguments[0]
var filename = arguments[1]
var file = File.new()
var path = 'user://%s' % filename
file.open(path, File.WRITE)
file.store_string(text)
file.close()
get_parent().open(path)
$Label.hide()
func save_as(file_path):
if not file_path:
file_path = 'UnnamedDialogue.wol'
JavaScript.download_buffer(get_parent().serialize_to_file().to_utf8(), file_path.get_file())

View file

@ -152,6 +152,7 @@ func _on_options(options):
button.text = option.line.text
button.connect('pressed', self, '_on_option_pressed', [option])
button.show()
button.grab_focus()
func _on_option_pressed(option):
add_message('Selected option "%s"' % option.line.text)

View file

@ -14,10 +14,6 @@ onready var original_delete_node_dialog = $DeleteNodeDialog.dialog_text
onready var original_unsaved_dialog = $UnsavedDialog.dialog_text
onready var inside_godot_editor = not get_tree().current_scene and Engine.editor_hint
# Standalone
# TODO: Make arrow keys select options in preview
# FIXME: Fix focus issues while being in-editor
# Godot Editor
# FIXME: Make all parts of the code "tool"s and safekeep its execution while in editora
# FIXME: Hide console when viewing Wol main screen
@ -76,8 +72,7 @@ func _ready():
$HBoxContainer.set('custom_constants/seperation', 0)
open('res://dialogue.wol')
update_title()
func create_node(position = Vector2.ZERO):
var graph_node = GraphNodeTemplate.duplicate()
@ -161,19 +156,22 @@ func serialize_to_file():
return PoolStringArray(buffer).join('\n')
func save_as(file_path = null):
if not file_path:
$FileDialog.mode = $FileDialog.MODE_SAVE_FILE
# TODO: Set up path based on context (Godot editor, standalone or web)
$FileDialog.popup_centered()
file_path = yield($FileDialog, 'file_selected')
if $Javascript:
$Javascript.save_as(file_path)
else:
if not file_path:
return
var file = File.new()
file.open(file_path, File.WRITE)
file.store_string(serialize_to_file())
file.close()
$FileDialog.mode = $FileDialog.MODE_SAVE_FILE
# TODO: Set up path based on context (Godot editor, standalone or web)
$FileDialog.popup_centered()
file_path = yield($FileDialog, 'file_selected')
if not file_path:
return
var file = File.new()
file.open(file_path, File.WRITE)
file.store_string(serialize_to_file())
file.close()
saved_all_changes = true
last_save = serialize_to_file()
@ -352,8 +350,9 @@ func move_focus():
> node.center.distance_to(current_focussed.center + focus_pan):
closest = node
$GraphEdit.set_selected(closest)
closest.grab_focus()
if closest:
$GraphEdit.set_selected(closest)
closest.grab_focus()
focus_pan = null
@ -435,8 +434,9 @@ func _input(event):
return save_as()
'Control+O':
return open()
if event.pressed:
focus_pan = Input.get_vector('ui_left', 'ui_right', 'ui_up', 'ui_down') * 500
elif focus_pan:
move_focus()
if not $HBoxContainer/Editor.visible:
if event.pressed:
focus_pan = Input.get_vector('ui_left', 'ui_right', 'ui_up', 'ui_down') * 500
elif focus_pan:
move_focus()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=2]
[gd_scene load_steps=29 format=2]
[ext_resource path="res://addons/Wol/editor/Editor.gd" type="Script" id=1]
[ext_resource path="res://addons/Wol/editor/WolEditor.gd" type="Script" id=2]
@ -17,9 +17,22 @@
[ext_resource path="res://addons/Wol/font/Aileron-SemiBoldItalic.otf" type="DynamicFontData" id=15]
[ext_resource path="res://addons/Wol/font/Aileron-Italic.otf" type="DynamicFontData" id=16]
[ext_resource path="res://addons/Wol/editor/Help.gd" type="Script" id=17]
[ext_resource path="res://addons/Wol/logo.svg" type="Texture" id=18]
[ext_resource path="res://addons/Wol/editor/Javascript.gd" type="Script" id=19]
[sub_resource type="StyleBoxEmpty" id=2]
[sub_resource type="Shader" id=334]
code = "shader_type canvas_item;
void fragment() {
vec4 color = texture(TEXTURE, UV);
COLOR = vec4(1.0 - color.rgb, color.a);
}"
[sub_resource type="ShaderMaterial" id=335]
shader = SubResource( 334 )
[sub_resource type="StyleBoxFlat" id=328]
bg_color = Color( 0.345098, 0.345098, 0.345098, 1 )
corner_radius_top_left = 8
@ -68,6 +81,30 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Javascript" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
input_pass_on_modal_close_click = false
script = ExtResource( 19 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Javascript"]
modulate = Color( 1, 1, 1, 0.3 )
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -20.0
margin_top = -10.0
margin_right = 20.0
margin_bottom = 10.0
grow_horizontal = 2
grow_vertical = 2
text = "Drag in a file to get started!"
[node name="Tween" type="Tween" parent="."]
[node name="Menu" type="HBoxContainer" parent="."]
@ -77,16 +114,23 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="FrontPadding" type="Control" parent="Menu"]
margin_bottom = 32.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="File" type="MenuButton" parent="Menu"]
margin_right = 38.0
margin_left = 8.0
margin_right = 46.0
margin_bottom = 32.0
text = "File"
items = [ "New", null, 0, false, false, 0, 0, null, "", false, "Open", null, 0, false, false, 1, 0, null, "", false, "Save", null, 0, false, false, 2, 0, null, "", false, "Save as...", null, 0, false, false, 3, 0, null, "", false ]
switch_on_hover = true
[node name="Settings" type="Button" parent="Menu"]
margin_left = 46.0
margin_right = 116.0
margin_left = 54.0
margin_right = 124.0
margin_bottom = 32.0
focus_mode = 0
enabled_focus_mode = 0
@ -94,8 +138,8 @@ text = "Settings"
flat = true
[node name="Help" type="Button" parent="Menu"]
margin_left = 124.0
margin_right = 171.0
margin_left = 132.0
margin_right = 179.0
margin_bottom = 32.0
focus_mode = 0
enabled_focus_mode = 0
@ -103,8 +147,8 @@ text = "Help"
flat = true
[node name="About" type="Button" parent="Menu"]
margin_left = 179.0
margin_right = 234.0
margin_left = 187.0
margin_right = 242.0
margin_bottom = 32.0
focus_mode = 0
enabled_focus_mode = 0
@ -121,7 +165,7 @@ size_flags_horizontal = 10
text = "By @bram_dingelstad"
flat = true
[node name="Padding" type="Control" parent="Menu"]
[node name="BackPadding" type="Control" parent="Menu"]
margin_left = 1024.0
margin_right = 1024.0
margin_bottom = 32.0
@ -216,13 +260,37 @@ anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 32.0
custom_styles/bg = SubResource( 2 )
scroll_offset = Vector2( 0, -511 )
snap_distance = 100
show_zoom_label = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="GraphEdit"]
modulate = Color( 1, 1, 1, 0.2 )
material = SubResource( 335 )
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 16.9979
margin_top = -92.0011
margin_right = 141.998
margin_bottom = -29.001
texture = ExtResource( 18 )
expand = true
stretch_mode = 7
[node name="Label" type="Label" parent="GraphEdit/TextureRect"]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 10.0013
margin_top = -2.00079
margin_right = 116.001
margin_bottom = 17.9992
text = "version alpha2"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchor_top = 0.053
anchor_right = 1.0
@ -590,7 +658,11 @@ margin_right = 297.0
margin_bottom = 231.0
rect_min_size = Vector2( 400, 140 )
resizable = true
access = 2
filters = PoolStringArray( "*.yarn", "*.wol" )
current_dir = "/Users/bram/Development/Wol"
current_file = "Users"
current_path = "/Users/bram/Development/Wol/Users"
__meta__ = {
"_edit_use_anchors_": false
}
@ -678,7 +750,7 @@ margin_right = 26.5
margin_bottom = 8.0
grow_horizontal = 2
grow_vertical = 2
text = "Wol (alpha1)"
text = "Wol (alpha2)"
align = 1
valign = 1
@ -720,7 +792,6 @@ custom_fonts/bold_font = SubResource( 333 )
custom_fonts/normal_font = SubResource( 329 )
bbcode_enabled = true
bbcode_text = "[b]Keyboard shortcuts[/b]
[s]Line through = not yet implemented[/s]
[i]Anywhere[/i]
New
@ -733,15 +804,19 @@ Open
[right]Ctrl/Cmd + O[/right]
[i]Node view[/i]
[s]WASD / Arrows[/s]
WASD / Arrows
[right]move focus[/right]
[s]Enter / Dbl click[/s]
Enter / Dbl click
[right]open node in editor[/right]
Dbl click background
[right]New node[/right]
Delete
[right]Delete selected node[/right]
[i]Editor[/i]
Escape
[right]Close editor[/right]
[s]Ctrl/Cmd + P[/s]
Ctrl/Cmd + P
[right]Play node[/right]
[i]Preview[/i]
@ -750,7 +825,6 @@ Space
."
text = "Keyboard shortcuts
Line through = not yet implemented
Anywhere
New
@ -767,6 +841,10 @@ WASD / Arrows
move focus
Enter / Dbl click
open node in editor
Dbl click background
New node
Delete
Delete selected node
Editor
Escape

View file

@ -13,8 +13,8 @@ func _enter_tree():
load('res://addons/Wol/icon-white.svg')
)
wol_editor_instance = WolEditor.instance()
get_editor_interface().get_editor_viewport().add_child(wol_editor_instance)
# wol_editor_instance = WolEditor.instance()
# get_editor_interface().get_editor_viewport().add_child(wol_editor_instance)
make_visible(false)
@ -37,11 +37,11 @@ func make_visible(visible):
func _exit_tree():
remove_custom_type('Wol')
if wol_editor_instance:
wol_editor_instance.queue_free()
# if wol_editor_instance:
# wol_editor_instance.queue_free()
func has_main_screen():
return true
# func has_main_screen():
# return true
func get_plugin_name():
return 'Wol'

BIN
addons/Wol/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
path="res://.import/splash.png-05acbe07b52e4ead055a092edeb6a3bc.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
source_file="res://addons/Wol/splash.png"
dest_files=[ "res://.import/splash.png-05acbe07b52e4ead055a092edeb6a3bc.stex" ]
[params]

5
change-version.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
$old_version=$1
$new_version=$2
ggrep -niR "$old_version" 2>/dev/null | cut -d : -f1 | uniq | while read -r file; do gsed -i "s/$old_version/
$new_version/g" "$file"; done

View file

@ -10,34 +10,6 @@ Narrator: Do you want to continue talking?
[[Start]]
-> No
===
title: Start
tags:
colorID:
position: 500, -400
---
<<a_custom_command>>
<<command_with multiple arguments>>
// remove "to" to trigger error
<<set $direction to "that">>
<<set $one to 1>>
// Implement inline expressions
<<if visit_count() == 1>>
Narrator: You, {$direction} way!
<<endif>>
Narrator: Do you know you've been here {visit_count()} times?
You: Did you know one + one equals {$one + $one}?
Narrator: You wanna go somewhere?
-> Go to the store
[[TheStore]]
-> How much did I visit the store?
Narrator: You've been to the store { visit_count("TheStore") } times.
[[Start]]
-> Lets stay here and talk
[[Talk]]
===
title: TheStore
tags:
colorID:
@ -68,4 +40,33 @@ You: IM AT THE SOUP STORE!!
Guy: WHY ARE YOU BUYING CLOTHES AT THE SOUP STORE?!
You: FUCK YOU!
[[Go home|Start]]
===
title: Start
tags:
colorID:
position: 500, -400
---
<<a_custom_command>>
<<command_with multiple arguments>>
// remove "to" to trigger error
<<set $direction to "that">>
<<set $one to 1>>
// Implement inline expressions
<<if visit_count() == 1>>
Narrator: You, {$direction} way!
<<endif>>
Narrator: Do you know you've been here {visit_count()} times?
You: Did you know one + one equals {$one + $one}?
<<set $value to "option1">>
Narrator: You wanna go somewhere [select {$value} option1="yonder" option2="here"]?
-> Go to the store
[[TheStore]]
-> How much did I visit the store?
Narrator: You've been to the store { visit_count("TheStore") } times.
[[Start]]
-> Lets stay here and talk
[[Talk]]
===

View file

@ -2,12 +2,12 @@
name="Mac OSX"
platform="Mac OSX"
runnable=true
runnable=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="export/osx/Wol.dmg"
export_path="export/osx/WolEditor.dmg"
script_export_mode=1
script_encryption_key=""
@ -16,21 +16,21 @@ script_encryption_key=""
custom_template/debug=""
custom_template/release=""
application/name="Wol Editor"
application/info="Wol Editor: a editor for Yarn and Wol files"
application/info="Wol Editor: an editor for Yarn and Wol files"
application/icon=""
application/identifier="works.dingelstad.bram.woleditor"
application/signature=""
application/app_category="Developer-tools"
application/short_version="1.0"
application/version="1.0"
application/copyright="© Bram Dingelstad"
application/short_version="alpha2"
application/version="alpha2"
application/copyright="MIT License: Bram Dingelstad, kyperbelt, Secret Labs"
display/high_res=true
privacy/camera_usage_description=""
privacy/microphone_usage_description=""
codesign/enable=false
codesign/identity=""
codesign/enable=true
codesign/identity="WolEditor"
codesign/timestamp=false
codesign/hardened_runtime=false
codesign/hardened_runtime=true
codesign/replace_existing_signature=false
codesign/entitlements/custom_file=""
codesign/entitlements/allow_jit_code_execution=false
@ -45,7 +45,7 @@ codesign/entitlements/calendars=false
codesign/entitlements/photos_library=false
codesign/entitlements/apple_events=false
codesign/entitlements/debugging=false
codesign/entitlements/app_sandbox/enabled=false
codesign/entitlements/app_sandbox/enabled=true
codesign/entitlements/app_sandbox/network_server=false
codesign/entitlements/app_sandbox/network_client=false
codesign/entitlements/app_sandbox/device_usb=false
@ -56,8 +56,8 @@ codesign/entitlements/app_sandbox/files_music=0
codesign/entitlements/app_sandbox/files_movies=0
codesign/custom_options=PoolStringArray( )
notarization/enable=false
notarization/apple_id_name=""
notarization/apple_id_password=""
notarization/apple_id_name="bram.dingelstad+apple@pm.me"
notarization/apple_id_password="?00f493b9945fDDB7Fb!"
notarization/apple_team_id=""
texture_format/s3tc=true
texture_format/etc=false
@ -97,3 +97,69 @@ progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color( 0, 0, 0, 1 )
[preset.2]
name="Windows Desktop"
platform="Windows Desktop"
runnable=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="export/windows/WolEditor.exe"
script_export_mode=1
script_encryption_key=""
[preset.2.options]
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=true
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
codesign/enable=false
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon=""
application/file_version="alpha2"
application/product_version="alpha2"
application/company_name="Dingelstad Works"
application/product_name="Wol Editor"
application/file_description=""
application/copyright="MIT: Bram Dingelstad, kyperbelt, Secret Labs"
application/trademarks=""
[preset.3]
name="Linux/X11"
platform="Linux/X11"
runnable=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="export/linux/WolEditor"
script_export_mode=1
script_encryption_key=""
[preset.3.options]
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=true
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -20,6 +20,8 @@ Yarn's similar in style to Twine, so if you already know that, you'll be right a
Wol is actively maintained by Bram Dingelstad, if you need a programmer or designer for your next (Godot) project, you can hire him!"
run/main_scene="res://addons/Wol/editor/WolEditor.tscn"
run/low_processor_mode=true
boot_splash/image="res://addons/Wol/splash.png"
boot_splash/fullsize=false
config/icon="res://addons/Wol/icon-white-with-stroke.svg"
[debug]