summaryrefslogtreecommitdiffhomepage
path: root/dragon
diff options
context:
space:
mode:
authorAmir Rajan <[email protected]>2020-08-03 18:09:21 -0500
committerAmir Rajan <[email protected]>2020-08-03 18:09:21 -0500
commit161d498dc905f04b595c927309993acdcb4d394c (patch)
treee9cc7f046ff07a93be8a5c69e5c4b2b0c6e74c61 /dragon
parente2703a351ef1dfa3f6ea72f9fd2814922729f0bb (diff)
downloaddragonruby-game-toolkit-contrib-161d498dc905f04b595c927309993acdcb4d394c.tar.gz
dragonruby-game-toolkit-contrib-161d498dc905f04b595c927309993acdcb4d394c.zip
synced with 1.13
Diffstat (limited to 'dragon')
-rw-r--r--dragon/args.rb21
-rw-r--r--dragon/docs.rb50
-rw-r--r--dragon/geometry.rb16
-rw-r--r--dragon/kernel_docs.rb1
4 files changed, 68 insertions, 20 deletions
diff --git a/dragon/args.rb b/dragon/args.rb
index 0e6ff6f..2c4c604 100644
--- a/dragon/args.rb
+++ b/dragon/args.rb
@@ -51,7 +51,7 @@ module GTK
def initialize runtime, recording
@inputs = Inputs.new
- @outputs = Outputs.new
+ @outputs = Outputs.new args: self
@passes = []
@state = OpenEntity.new
@state.tick_count = -1
@@ -89,13 +89,30 @@ module GTK
end
def clear_render_targets
+ render_targets_clear
+ end
+
+ def render_targets_clear
@render_targets = {}
end
+ def render_targets
+ @render_targets
+ end
+
def render_target name
+ if @state.tick_count == 0
+ log_important <<-S
+* WARNING:
+~render_target~ with name ~#{name}~ was created
+on ~args.state.tick_count == 0~. You cannot create ~render_targets~ on the
+first frame and need to wait until ~args.state.tick_count >= 1~.
+S
+ end
+
name = name.to_s
if !@render_targets[name]
- @render_targets[name] = Outputs.new(target: name, background_color_override: [255, 255, 255, 0])
+ @render_targets[name] = Outputs.new(args: self, target: name, background_color_override: [255, 255, 255, 0])
@passes << @render_targets[name]
end
@render_targets[name]
diff --git a/dragon/docs.rb b/dragon/docs.rb
index 16d9f3b..8f5e8bf 100644
--- a/dragon/docs.rb
+++ b/dragon/docs.rb
@@ -354,11 +354,17 @@ S
end
close_list_if_needed = lambda do |inside_ul, inside_ol|
- result = ""
- if inside_ul
- result = "</ul>\n"
- elsif inside_ol
- result = "</ol>\n"
+ begin
+ result = ""
+ if inside_ul
+ result = "</ul>\n"
+ elsif inside_ol
+ result = "</ol>\n"
+ else
+ result
+ end
+ rescue Exception => e
+ raise "* ERROR in determining close_list_if_needed lambda result. #{e}."
end
end
@@ -370,39 +376,39 @@ S
true_lines.each do |l|
parse_log << "** Processing line: ~#{l.rstrip}~"
if l.start_with? "* "
+ parse_log << "- H1 detected."
content_html += close_list_if_needed.call inside_ul, inside_ol
inside_ol = false
inside_ul = false
formatted_html = __docs_line_to_html__ l, parse_log
link_id = text_to_id.call l
toc += "<li><a href='##{link_id}'>#{formatted_html}</a></li>\n"
- parse_log << "- H1 detected."
content_html += "<h1 id='#{link_id}'>#{formatted_html}</h1>\n"
elsif l.start_with? "** "
+ parse_log << "- H2 detected."
content_html += close_list_if_needed.call inside_ul, inside_ol
inside_ol = false
inside_ul = false
formatted_html = __docs_line_to_html__ l, parse_log
link_id = text_to_id.call l
# toc += "<a href='##{link_id}'>#{formatted_html}</a></br>\n"
- parse_log << "- H2 detected."
content_html += "<h2>#{__docs_line_to_html__ l, parse_log}</h2>\n"
elsif l.start_with? "*** "
+ parse_log << "- H3 detected."
content_html += close_list_if_needed.call inside_ul, inside_ol
inside_ol = false
inside_ul = false
formatted_html = __docs_line_to_html__ l, parse_log
link_id = text_to_id.call l
# toc += "<a href='##{link_id}'>#{formatted_html}</a></br>\n"
- parse_log << "- H3 detected."
content_html += "<h3>#{__docs_line_to_html__ l, parse_log}</h3>\n"
elsif l.strip.length == 0 && !inside_pre
# do nothing
elsif l.start_with? "#+begin_src"
+ parse_log << "- PRE start detected."
content_html += close_list_if_needed.call inside_ul, inside_ol
inside_ol = false
inside_ul = false
- parse_log << "- PRE start detected."
inside_pre = true
content_html << "<pre>"
elsif l.start_with? "#+end_src"
@@ -412,16 +418,18 @@ S
inside_pre = false
content_html << "</pre>\n"
elsif l.start_with? "#+begin_quote"
+ parse_log << "- BLOCKQUOTE start detected."
content_html += close_list_if_needed.call inside_ul, inside_ol
inside_ol = false
inside_ul = false
- parse_log << "- BLOCKQUOTE start detected."
content_html << "<blockquote>\n"
elsif l.start_with? "#+end_quote"
parse_log << "- BLOCKQUOTE end detected."
content_html << "</blockquote>\n"
elsif (l.start_with? "1. ") && !inside_ol
parse_log << "- OL start detected."
+ parse_log << "- LI detected."
+
inside_ol = true
content_html << "<ol>\n"
@@ -432,9 +440,10 @@ S
elsif l.split(".")[0].length == 3
l = l[4..-1]
end
- parse_log << "- LI detected."
+
content_html << "<li>#{__docs_line_to_html__ l, parse_log}</li>\n"
elsif inside_ol && (l[1] == "." || l[2] == "." || l[3] == ".")
+ parse_log << "- LI detected."
if l.split(".")[0].length == 1
l = l[2..-1]
@@ -444,31 +453,34 @@ S
l = l[4..-1]
end
- parse_log << "- LI detected."
content_html << "<li>#{__docs_line_to_html__ l, parse_log}</li>\n"
elsif (l.start_with? "- ") && !inside_ul
parse_log << "- UL start detected."
+ parse_log << "- LI detected."
+
inside_ul = true
content_html << "<ul>\n"
l = l[2..-1]
- parse_log << "- LI detected."
content_html << "<li>#{__docs_line_to_html__ l, parse_log}</li>\n"
elsif (l.start_with? "- ") && inside_ul
+ parse_log << "- LI detected."
+
l = l[2..-1]
- parse_log << "- LI detected."
content_html << "<li>#{__docs_line_to_html__ l, parse_log}</li>\n"
else
if inside_ul
- inside_ul = false
parse_log << "- UL end detected."
+
+ inside_ul = false
content_html << "</ul>\n"
end
if inside_ol
- inside_ol = false
parse_log << "- OL end detected."
+
+ inside_ol = false
content_html << "</ol>\n"
end
@@ -476,6 +488,7 @@ S
content_html << "#{l.rstrip[2..-1]}\n"
else
parse_log << "- P detected."
+
content_html << "<p>\n#{__docs_line_to_html__ l, parse_log}\n</p>\n"
end
end
@@ -490,6 +503,9 @@ S
html: final_html,
parse_log: parse_log
}
+ rescue Exception => e
+ $gtk.write_file 'docs/parse_log.txt', (parse_log.join "\n")
+ raise "* ERROR in Docs::__docs_to_html__. #{e}"
end
def __docs_line_to_html__ line, parse_log
@@ -558,7 +574,7 @@ S
return line_to_format
rescue Exception => e
- parse_log << "Failed to parse line: ~#{line}~, #{e}"
+ parse_log << "* ERROR: Failed to parse line: ~#{line}~, #{e}"
return line.rstrip
end
end
diff --git a/dragon/geometry.rb b/dragon/geometry.rb
index 1be0379..59f1865 100644
--- a/dragon/geometry.rb
+++ b/dragon/geometry.rb
@@ -76,6 +76,20 @@ module GTK
Geometry.point_inside_circle? self, circle_center_point, radius
end
+ def center_inside_rect other_rect
+ offset_x = (other_rect.w - w).half
+ offset_y = (other_rect.h - h).half
+ new_rect = self.shift_rect(0, 0)
+ new_rect.x = other_rect.x + offset_x
+ new_rect.y = other_rect.y + offset_y
+ new_rect
+ rescue Exception => e
+ raise e, <<-S
+* ERROR:
+center_inside_rect for self #{self} and other_rect #{other_rect}. Failed with exception #{e}.
+S
+ end
+
# Returns a primitive that is anchored/repositioned based off its retangle.
# @gtk
def anchor_rect anchor_x, anchor_y
@@ -83,7 +97,7 @@ module GTK
current_h = self.h
delta_x = -1 * (anchor_x * current_w)
delta_y = -1 * (anchor_y * current_h)
- self.rect_shift(delta_x, delta_y)
+ self.shift_rect(delta_x, delta_y)
end
def angle_given_point other_point
diff --git a/dragon/kernel_docs.rb b/dragon/kernel_docs.rb
index 0a91b4d..1f4977b 100644
--- a/dragon/kernel_docs.rb
+++ b/dragon/kernel_docs.rb
@@ -49,6 +49,7 @@ S
DocsOrganizer.sort_docs_classes!
final_string = ""
$docs_classes.each do |k|
+ log "* INFO: Retrieving docs for #{k.name}."
final_string += k.docs_all
end