rbgooey 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/check.rb ADDED
@@ -0,0 +1,48 @@
1
+ #Copyright (C) 2006-2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: Load all the part of the library
22
+
23
+ class Check
24
+ attr_accessor :display , :n
25
+ def initialize display
26
+ @display = display
27
+ @fg = @display.fg
28
+ @bg = @display.bg
29
+ @screen = @display.screen
30
+ check()
31
+ end
32
+ def check
33
+ @n = []
34
+ if @screen == nil
35
+ puts"You forgot to Display#setup"
36
+ n << 1
37
+ end
38
+ if @fg == nil || @bg == nil
39
+ puts"You forgot to Display#color"
40
+ n << 2
41
+ end
42
+ if @n == []
43
+ return true
44
+ else
45
+ return @n
46
+ end
47
+ end
48
+ end
data/lib/display.rb ADDED
@@ -0,0 +1,53 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This class contain basic display screen setting as well as colors.
22
+
23
+ class Display
24
+ attr_accessor :x , :y , :cursor , :flags , :screen , :fg , :bg
25
+ def initialize
26
+ @flags = [Rubygame::HWSURFACE, Rubygame::DOUBLEBUF]
27
+ end
28
+ #set up the screen
29
+ def setup x , y , cursor
30
+ @x = x
31
+ @y = y
32
+ @cursor = cursor
33
+ screenmode()
34
+ end
35
+ #Make the display screen.
36
+ def screenmode
37
+ @screen = Rubygame::Screen.new([@x,@y],0, @flags)
38
+ @screen.show_cursor = @cursor
39
+ end
40
+ #set up the color
41
+ def color fg , bg
42
+ @fg = fg
43
+ @bg = bg
44
+ end
45
+ #add a certain flag
46
+ def addflag n
47
+ case n
48
+ when 1
49
+ @flags << Rubygame::FULLSCREEN
50
+ end
51
+ screenmode()
52
+ end
53
+ end
data/lib/files.rb ADDED
@@ -0,0 +1,34 @@
1
+ #Copyright (C) 2006-2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: rbgooey
20
+ #DESCRIPTION: A GUI library for the Rubygame library
21
+ #FUNCTION OF THIS PART: Yaml file loading system.
22
+
23
+ class FileSys
24
+ #Read the file
25
+ def yaml_read filename
26
+ yaml_string = File.read filename; YAML:: load yaml_string
27
+ end
28
+ #Write to the file
29
+ def yaml_write object , filename
30
+ File.open filename , 'w' do |f|
31
+ f.write(object.to_yaml)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: Class ImageRender rendered materials created by ImageUi
22
+
23
+ class ImageRender
24
+ attr_accessor :ui
25
+ def initialize ui
26
+ @ui = ui
27
+ end
28
+ #render the last image added
29
+ def render image , x , y
30
+ key = image.get_at(0,0)
31
+ image.set_colorkey(key)
32
+ image.blit(@ui.display.screen,[x,y])
33
+ @ui.name[@ui.status][1] << Rect.new(x,y,*image.size)
34
+ end
35
+ end
data/lib/imageui.rb ADDED
@@ -0,0 +1,48 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This class deal with text manpluication
22
+
23
+ class ImageUi
24
+ attr_accessor :ui , :dir , :render
25
+ def initialize ui
26
+ @ui = ui
27
+ @render = ImageRender.new(@ui)
28
+ end
29
+ #Set ui image's directory location
30
+ def setup n
31
+ @dir = n
32
+ end
33
+ #Add a image
34
+ def add image, x, y
35
+ image = Rubygame::Surface.load_image("#{@dir}/#{image}")
36
+ @ui.image << image
37
+ @ui.name[@ui.status][0] << @ui.image.length - 1
38
+ @ui.name[@ui.status][3] << "image"
39
+ @render.render(image,x,y)
40
+ end
41
+ #Piece of code are called when the image collide with the mouse
42
+ def active &action
43
+ @ui.action << action
44
+ @ui.name[@ui.status][2] << @ui.action.length - 1
45
+ @ui.rect << @ui.name[@ui.status][1].last
46
+ @ui.name[@ui.status][1][-1] = @ui.rect.length - 1
47
+ end
48
+ end
data/lib/mouse.rb ADDED
@@ -0,0 +1,53 @@
1
+ #Copyright (C) 2006-2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This is class Mouse that deal with mouse related functions.
22
+
23
+ class Mouse
24
+ attr_accessor :image , :rect , :pos
25
+ include Rubygame::Sprites::Sprite
26
+ #The mouse take an image instead of a plain back cursor
27
+ def initialize
28
+ super
29
+ @pos = [0,0]
30
+ @rect = Rubygame::Rect.new(0,0,1,1)
31
+ end
32
+ def setup name
33
+ @image , @rect = load(name)
34
+ end
35
+ def load name
36
+ image = Rubygame::Surface.load_image(name)
37
+ return image, Rubygame::Rect.new(0,0,*image.size)
38
+ end
39
+ #Move the mouse
40
+ def tell tell
41
+ case tell
42
+ when Rubygame::MouseMotionEvent
43
+ @pos = tell.pos
44
+ end
45
+ end
46
+ #Update's mouse rect
47
+ def update
48
+ @rect.midtop = @pos
49
+ end
50
+ def undraw(dest, background)
51
+ background.blit(dest,@rect,@rect)
52
+ end
53
+ end
data/lib/rbgooey.rb ADDED
@@ -0,0 +1,38 @@
1
+ #Copyright (C) 2006-2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: Load all the parts of the library
22
+
23
+ require"rubygems"
24
+ require"check.rb"
25
+ require"display.rb"
26
+ require"files.rb"
27
+ require"imagerender.rb"
28
+ require"imageui.rb"
29
+ require"mouse.rb"
30
+ require"rectcollide.rb"
31
+ require"setup.rb"
32
+ require"text.rb"
33
+ require"textrender.rb"
34
+ require"type.rb"
35
+ require"typelowercase.rb"
36
+ require"typelowerspecial.rb"
37
+ require"typespecialcommands.rb"
38
+ require"uidata.rb"
@@ -0,0 +1,42 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: Deal with collision detection algorithm.
22
+
23
+ class RectCollide
24
+ attr_accessor :ui
25
+ def initialize ui
26
+ @ui = ui
27
+ end
28
+ def check
29
+ @count = 0
30
+ @ui.rect.each do |rect|
31
+ if @ui.mouse.rect.collide_rect?(rect)
32
+ action()
33
+ return @count
34
+ end
35
+ @count += 1
36
+ end
37
+ return false
38
+ end
39
+ def action
40
+ @ui.action[@count].call()
41
+ end
42
+ end
data/lib/setup.rb ADDED
@@ -0,0 +1,70 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: rbgooey
20
+ #DESCRIPTION: A GUI library for the Rubygame library
21
+ #FUNCTION OF THIS PART: Setup everything needed for UiData using a yaml file
22
+
23
+ class Setup
24
+ attr_accessor :file, :ui
25
+ def initialize ui
26
+ @ui = ui
27
+ @file = FileSys.new
28
+ if @ui.display.class != Display
29
+ set()
30
+ end
31
+ @check = Check.new(@ui.display)
32
+ end
33
+ def set
34
+ @data = @file.yaml_read(@ui.display)
35
+ @ui.display = Display.new
36
+ @ui.display.setup(@data['x'],@data['y'],@data['cursor'])
37
+ if @data['fg'] != nil && @data['bg'] != nil
38
+ color()
39
+ end
40
+ if @data['flags'] != nil
41
+ flags()
42
+ end
43
+ if @data['font'] != nil && @data['size'] != nil
44
+ text()
45
+ end
46
+ if @data['mouse'] != nil
47
+ mouse()
48
+ end
49
+ if @data['dir'] != nil
50
+ dir()
51
+ end
52
+ end
53
+ def color
54
+ @ui.display.color([@data['fg'][0],@data['fg'][1],@data['fg'][2]],[@data['bg'][0],@data['bg'][1],@data['bg'][2]])
55
+ end
56
+ def flags
57
+ @data['flags'].each do |t|
58
+ @ui.display.addflag(t)
59
+ end
60
+ end
61
+ def text
62
+ @ui.text.setup(@data['font'],@data['size'])
63
+ end
64
+ def mouse
65
+ @ui.mouse.setup(@data['mouse'])
66
+ end
67
+ def dir
68
+ @ui.imageui.setup(@data['dir'])
69
+ end
70
+ end
data/lib/text.rb ADDED
@@ -0,0 +1,52 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This class deal with text manpluication
22
+
23
+ class Text
24
+ attr_accessor :ui , :render , :font , :size
25
+ def initialize ui
26
+ @ui = ui
27
+ @render = TextRender.new(@ui)
28
+ end
29
+ #Add a piece of text along with the location
30
+ def add string , x , y , bg = 0
31
+ @ui.string << string
32
+ @ui.name[@ui.status][0] << @ui.string.length - 1
33
+ @ui.name[@ui.status][3] << "text"
34
+ if bg != 0
35
+ @render.render(x,y,bg)
36
+ else
37
+ @render.render(x,y)
38
+ end
39
+ end
40
+ #Text class required a font name to load and the normal size
41
+ def setup font , size
42
+ @font = font
43
+ @size = size
44
+ end
45
+ #Assign certain code when a specific string collide.
46
+ def active &action
47
+ @ui.action << action
48
+ @ui.name[@ui.status][2] << @ui.action.length - 1
49
+ @ui.rect << @ui.name[@ui.status][1].last
50
+ @ui.name[@ui.status][1][-1] = @ui.rect.length - 1
51
+ end
52
+ end
data/lib/textrender.rb ADDED
@@ -0,0 +1,77 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: Class TextRender render texts.
22
+
23
+ class TextRender
24
+ attr_accessor :ui
25
+ def initialize ui
26
+ @ui = ui
27
+ @y_value = 0
28
+ @x = nil
29
+ @y = nil
30
+ end
31
+ def compare x , y
32
+ if @x == nil || @y == nil
33
+ @x = x
34
+ @y = y
35
+ return
36
+ end
37
+ unless @y == y && @x == x
38
+ @y_value = 0
39
+ end
40
+ end
41
+ def reset
42
+ @y_value -= @skip
43
+ @ui.name[@ui.status][1].pop()
44
+ end
45
+ #Render the last string
46
+ def render x , y , bg = @ui.display.bg, size = @ui.text.size
47
+ compare(x,y)
48
+ default = nil
49
+ @font = TTF.new("#{@ui.text.font}",size)
50
+ @skip = @font.line_skip()
51
+ render = @font.render("#{@ui.string.last}",true,@ui.display.fg,bg)
52
+ render.blit(@ui.display.screen,[x,y+=@y_value])
53
+ @ui.name[@ui.status][1] << Rect.new(x,y,*render.size)
54
+ @y_value+= @skip
55
+ end
56
+ #Draw a certain group of texts
57
+ def draw name
58
+ @ui.name[name][0].zip(@ui.name[name][1]).each do |string,rect|
59
+ if rect.length == 1
60
+ rect = @rect[rect]
61
+ end
62
+ string = @ui.string[string]
63
+ if string != nil
64
+ render = @font.render("#{string}",true,@ui.display.fg,@ui.display.bg)
65
+ render.blit(@ui.display.screen,[rect[0],rect[1]])
66
+ end
67
+ end
68
+ end
69
+ #Assign a background surface for redraw
70
+ def surface background
71
+ @background = background
72
+ end
73
+ #Undraw a certain group
74
+ def undraw
75
+ @background.blit(@ui.display.screen,[0,0])
76
+ end
77
+ end
data/lib/type.rb ADDED
@@ -0,0 +1,105 @@
1
+ #Copyright (C) 2007 Han Dao
2
+ #
3
+ #This program is free software: you can redistribute it and/or modify
4
+ #it under the terms of the GNU General Public License as published by
5
+ #the Free Software Foundation, either version 3 of the License, or
6
+ #(at your option) any later version.
7
+ #
8
+ #This program is distributed in the hope that it will be useful,
9
+ #but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ #GNU General Public License for more details.
12
+ #
13
+ #You should have received a copy of the GNU General Public License
14
+ #along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+
17
+ #PROJECT: Rbgooey
18
+ #DESCRIPTION: A GUI library for the rubygame library.
19
+ #FUNCTION OF THIS PART: This class deal with Typing operations.
20
+
21
+ class Type
22
+ attr_accessor :ui , :state , :string , :lower , :special , :command,:x , :y , :void
23
+ def initialize ui
24
+ @ui = ui
25
+ @void = false
26
+ @state = false
27
+ @lower = Lowercase.new(self)
28
+ @special = LowerSpecial.new(self)
29
+ @command = SpecialCommands.new(self)
30
+ end
31
+ #check the length of @ui.string
32
+ def length
33
+ @n = @ui.string.length + 1
34
+ end
35
+ #switch the state from false to true and vice versa
36
+ def switch
37
+ if @state == false
38
+ @state = true
39
+ length()
40
+ else
41
+ @state = false
42
+ end
43
+ end
44
+ #delete something
45
+ def delete
46
+ if @ui.string.length == @n
47
+ @string.chop!
48
+ @ui.string[@n - 2] = @string
49
+ if @string == ""
50
+ @ui.name[@ui.status][0].pop()
51
+ @ui.text.render.reset()
52
+ @ui.rect.pop()
53
+ @ui.string.pop()
54
+ end
55
+ end
56
+ end
57
+ #rendering the typing
58
+ def render
59
+ if @string == ""
60
+ return
61
+ end
62
+ if @ui.string.length != @n
63
+ @ui.text.add(@string,@x,@y)
64
+ elsif @ui.string.length == @n
65
+ @ui.string[@n - 2] = @string
66
+ @ui.text.render.reset()
67
+ @ui.text.render.render(@x,@y)
68
+ end
69
+ end
70
+ #type a specific letter
71
+ def type letter
72
+ if @string == ""
73
+ @string = letter
74
+ else
75
+ @string << letter
76
+ end
77
+ render()
78
+ end
79
+ #set up the position of where the typing will occur
80
+ def position x , y
81
+ if @state == false
82
+ @x = x
83
+ @y = y
84
+ end
85
+ end
86
+ #typing beings when state is true
87
+ def active ev
88
+ if @state == true
89
+ if @string == nil
90
+ @string = ""
91
+ end
92
+ @lower.action(ev)
93
+ @special.action(ev)
94
+ @command.action(ev)
95
+ end
96
+ end
97
+ #cleanup data to begin a new line
98
+ def clean
99
+ @state = false
100
+ @x = nil
101
+ @y = nil
102
+ @string = nil
103
+ @void = true
104
+ end
105
+ end
@@ -0,0 +1,86 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This class is responsible for lowercase typing.
22
+
23
+ class Lowercase
24
+ def initialize t
25
+ @t = t
26
+ end
27
+ def action ev
28
+ case ev
29
+ when Rubygame::KeyDownEvent
30
+ case ev.key
31
+ when Rubygame::K_A
32
+ @t.type("a")
33
+ when Rubygame::K_B
34
+ @t.type("b")
35
+ when Rubygame::K_C
36
+ @t.type("c")
37
+ when Rubygame::K_D
38
+ @t.type("d")
39
+ when Rubygame::K_E
40
+ @t.type("e")
41
+ when Rubygame::K_F
42
+ @t.type("f")
43
+ when Rubygame::K_G
44
+ @t.type("g")
45
+ when Rubygame::K_H
46
+ @t.type("h")
47
+ when Rubygame::K_I
48
+ @t.type("i")
49
+ when Rubygame::K_J
50
+ @t.type("j")
51
+ when Rubygame::K_K
52
+ @t.type("k")
53
+ when Rubygame::K_L
54
+ @t.type("l")
55
+ when Rubygame::K_M
56
+ @t.type("m")
57
+ when Rubygame::K_N
58
+ @t.type("n")
59
+ when Rubygame::K_O
60
+ @t.type("o")
61
+ when Rubygame::K_P
62
+ @t.type("p")
63
+ when Rubygame::K_Q
64
+ @t.type("q")
65
+ when Rubygame::K_R
66
+ @t.type("r")
67
+ when Rubygame::K_S
68
+ @t.type("s")
69
+ when Rubygame::K_T
70
+ @t.type("t")
71
+ when Rubygame::K_U
72
+ @t.type("u")
73
+ when Rubygame::K_V
74
+ @t.type("v")
75
+ when Rubygame::K_W
76
+ @t.type("w")
77
+ when Rubygame::K_X
78
+ @t.type("x")
79
+ when Rubygame::K_Y
80
+ @t.type("y")
81
+ when Rubygame::K_Z
82
+ @t.type("z")
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,64 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This class is responsible for lowercase typing.
22
+
23
+ class LowerSpecial
24
+ def initialize t
25
+ @t = t
26
+ end
27
+ def action ev
28
+ case ev
29
+ when Rubygame::KeyDownEvent
30
+ case ev.key
31
+ when Rubygame::K_0
32
+ @t.type("0")
33
+ when Rubygame::K_1
34
+ @t.type("1")
35
+ when Rubygame::K_2
36
+ @t.type("2")
37
+ when Rubygame::K_3
38
+ @t.type("3")
39
+ when Rubygame::K_4
40
+ @t.type("4")
41
+ when Rubygame::K_5
42
+ @t.type("5")
43
+ when Rubygame::K_6
44
+ @t.type("6")
45
+ when Rubygame::K_7
46
+ @t.type("7")
47
+ when Rubygame::K_8
48
+ @t.type("8")
49
+ when Rubygame::K_9
50
+ @t.type("9")
51
+ when Rubygame::K_SLASH
52
+ @t.type("/")
53
+ when Rubygame::K_MINUS
54
+ @t.type("-")
55
+ when Rubygame::K_QUOTE
56
+ @t.type("\'")
57
+ when Rubygame::K_PERIOD
58
+ @t.type(".")
59
+ when Rubygame::K_SPACE
60
+ @t.type(" ")
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,40 @@
1
+ #Copyright (C) 2007 by Han Dao
2
+
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program; if not, write to the Free Software
15
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ #
17
+ #You can contract the author at wikipediankiba@gmail.com
18
+
19
+ #PROJECT: Rbgooey
20
+ #DESCRIPTION: A GUI library for the rubygame library.
21
+ #FUNCTION OF THIS PART: This class is responsible for lowercase typing.
22
+
23
+ class SpecialCommands
24
+ def initialize t
25
+ @t = t
26
+ end
27
+ def action ev
28
+ case ev
29
+ when Rubygame::KeyDownEvent
30
+ case ev.key
31
+ when Rubygame::K_BACKSPACE
32
+ @t.delete()
33
+ when Rubygame::K_RETURN
34
+ if @t.void == false
35
+ @t.state = false
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
data/lib/uidata.rb ADDED
@@ -0,0 +1,50 @@
1
+ #Copyright (C) 2007 Han Dao
2
+ #
3
+ #This program is free software: you can redistribute it and/or modify
4
+ #it under the terms of the GNU General Public License as published by
5
+ #the Free Software Foundation, either version 3 of the License, or
6
+ #(at your option) any later version.
7
+ #
8
+ #This program is distributed in the hope that it will be useful,
9
+ #but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ #GNU General Public License for more details.
12
+ #
13
+ #You should have received a copy of the GNU General Public License
14
+ #along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #PROJECT: rbgooey
17
+ #DESCRIPTION: A GUI library for the rubygame library.
18
+ #FUNCTION OF THIS PART: This class deal with GUI elements
19
+
20
+ class UiData
21
+ attr_accessor :display , :name , :rect , :string , :text , :status , :action , :collide , :mouse , :type , :setup , :image , :imageui
22
+ #display can be the name of yaml file you wanted to load or the Display class.
23
+ def initialize display
24
+ @display = display
25
+ @name = {}
26
+ @rect = []
27
+ @string = []
28
+ @action = []
29
+ @image = []
30
+ @text = Text.new(self)
31
+ @collide = RectCollide.new(self)
32
+ @mouse = Mouse.new()
33
+ @type = Type.new(self)
34
+ @imageui = ImageUi.new(self)
35
+ @setup = Setup.new(self)
36
+ end
37
+ #Make a group of UI items to associate with
38
+ def declare name
39
+ @status = name
40
+ @name[name] = [[],[],[],[]]
41
+ end
42
+ #Clear everything
43
+ def clear
44
+ @name = {}
45
+ @status = nil
46
+ @rect.clear()
47
+ @string.clear()
48
+ @action.clear()
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: rbgooey
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.3
7
+ date: 2008-05-31 00:00:00 -04:00
8
+ summary: GUI library for the Rubygame library
9
+ require_paths:
10
+ - - lib
11
+ email: wikipediankiba@gmail.com
12
+ homepage: http://rbgooey.rubyforge.org
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: rbgooey.rb
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Han Dao
31
+ files:
32
+ - lib/check.rb
33
+ - lib/imageui.rb
34
+ - lib/type.rb
35
+ - lib/imagerender.rb
36
+ - lib/textrender.rb
37
+ - lib/text.rb
38
+ - lib/typelowercase.rb
39
+ - lib/mouse.rb
40
+ - lib/rectcollide.rb
41
+ - lib/typelowerspecial.rb
42
+ - lib/setup.rb
43
+ - lib/files.rb
44
+ - lib/typespecialcommands.rb
45
+ - lib/display.rb
46
+ - lib/rbgooey.rb
47
+ - lib/uidata.rb
48
+ test_files: []
49
+
50
+ rdoc_options: []
51
+
52
+ extra_rdoc_files: []
53
+
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ requirements: []
59
+
60
+ dependencies: []
61
+