forked from hacketyhack/hacketyhack
/
mainwindow.rb
executable file
·136 lines (120 loc) · 3.46 KB
/
mainwindow.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
require 'app/boot'
require 'json'
# methods for the main app
module HH::App
# starts a lesson
# returns only once the lesson gets closed
include HH::Markup
def start_lessons name, blk, lesson_area
@main_content.style(:width => -400)
@lesson_stack = lesson_area
@lesson_stack.show
l = HH::LessonSet.new(name, blk).execute_in @lesson_stack
l.on_event :close do hide_lesson end
end
def hide_lesson
#@lesson_stack.hide
#@main_content.style(:width => 1.0)
@lesson_stack.clear
end
def load_file name={}
if gettab(:Editor).load(name)
opentab :Editor
end
end
# replaces the "Running..." message of the currently running program
def say arg
# FIXME TODO: DECOMMENT TO REPRODUCE A SEGMENTATION FAULT: para (para "abc")
if @program_running
txt = case arg
when String
arg
else
highlight(txt.inspect)
end
@program_running.clear{para txt}
end
end
def finalization
# this method gets called on close
HH::LessonSet.close_lesson
gettab(:Editor).save_if_confirmed
HH::PREFS['width'] = width
HH::PREFS['height'] = height
HH::save_prefs
end
end
w = (HH::PREFS['width'] || '790').to_i
h = (HH::PREFS['height'] || '550').to_i
Shoes.app :title => "Hackety Hack", :width => w, :height => h do
HH::APP = self
extend HH::App, HH::Widgets, HH::Observable
style Shoes::LinkHover, stroke: "#C66", underline: false
style Shoes::Link, stroke: "#377", underline: false
nostroke
alias :icon_button :iconbutton
@main_content = flow do
background "#e9efe0", height: h
flow margin_top: h - 150 do
flow{background "#e9efe0".."#c1c5d0", height: 150}
end
end
#@lesson_stack = stack :hidden => true, :width => 400
#@lesson_stack.finish do
# finalization
#end
extend HH::HasSideTabs
init_tabs @main_content
addtab :Home, :icon => "tab-home.png"
addtab :Editor, :icon => "tab-new.png"
addtab :Lessons, :icon => "tab-tour.png"
addtab :Help, :icon => "tab-help.png" do
Shoes.show_manual 'English'
end
addtab :Cheat, :icon => "tab-cheat.png" do
window :title => "Hackety Hack - Cheat Sheet", :width => 496 do
image "#{HH::STATIC}/hhcheat.png"
end
end
addtab :About, :icon => "tab-hand.png" do
about = []
about << rect(100, 30, width-170, height-60, fill: white)
about << image("#{HH::STATIC}/hhabout.png", top: 30, left: 100)
glossb "OK", left: width-170, top: height-100, width:50, height: 30, margin: [13, 5], color: "dark" do
about.clear
about[1].parent.contents.delete about[1]
end
end
13.times{addtab :Dummy}
addtab :Prefs, :hover => "Preferences", :icon => "tab-properties.png"
addtab :Quit, :icon => "tab-quit.png" do
exit
end
opentab :Home
=begin
@tour_notice =
stack :top => 46, :left => 22, :width => 250, :height => 54, :hidden => true do
fill black(0.6)
nostroke
shape 0, 20 do
line_to 23.6, 0
line_to 23.6, 10
line_to 0, 0
end
background black(0.6), :curve => 6, :left => 24, :width => 215
para "Check out the Hackety Hack Tour to get started!",
:stroke => "#FFF", :margin => 6, :size => 11, :margin_left => 22,
:align => "center"
end
# splash screen
stack :top => 0, :left => 0, :width => 1.0, :height => 1.0 do
splash
if HH::PREFS['first_run'].nil?
@tour_notice.toggle
@tour_notice.click { @tour_notice.hide }
HH::PREFS['first_run'] = true
HH::save_prefs
end
end
=end
end