• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revisiónfe6e2c7f8739c7094c5ef8af829eaa588370f690 (tree)
Tiempo2015-03-21 23:13:08
AutorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

update error checking(2)

Cambiar Resumen

Diferencia incremental

--- a/lib/ninix/dll.rb
+++ b/lib/ninix/dll.rb
@@ -100,7 +100,7 @@ module DLL
100100 for line in req.split("\n")
101101 line = line.force_encoding(@charset).strip.encode("UTF-8", :invalid => :replace)
102102 if line.empty?
103- continue
103+ next
104104 end
105105 if req_type == nil
106106 for request in ['EXECUTE', 'GET Version'] ## FIXME
@@ -111,7 +111,7 @@ module DLL
111111 next
112112 end
113113 if line.index(':') == nil
114- continue
114+ next
115115 end
116116 key, value = line.split(':', 2)
117117 key = key.strip()
--- a/lib/ninix/install.rb
+++ b/lib/ninix/install.rb
@@ -26,13 +26,13 @@ require "ninix/version"
2626
2727 module Install
2828
29-# class InstallError(Exception)
30-# # pass
31-# end
29+ class InstallError < Exception
30+ #pass
31+ end
3232
3333 def self.fatal(error)
34- logging.error(error) # XXX
35- raise InstallError(error)
34+ #logging.error(error) # XXX
35+ raise InstallError.new(error)
3636 end
3737
3838 class Installer
@@ -75,7 +75,7 @@ module Install
7575 if ['.nar', '.zip'].include?(ext)
7676 # pass
7777 else
78- fatal('unknown archive format')
78+ Install.fatal('unknown archive format')
7979 end
8080 end
8181
@@ -86,7 +86,7 @@ module Install
8686 begin
8787 FileUtils.mkdir_p(tmpdir)
8888 rescue # except:
89- fatal('cannot make temporary directory')
89+ Install.fatal('cannot make temporary directory')
9090 end
9191 url = nil
9292 if filename.start_with?('http:') or filename.start_with?('ftp:')
@@ -94,7 +94,7 @@ module Install
9494 filename = download(filename, tmpdir)
9595 if filename == nil
9696 FileUtils.remove_entry_secure(tmpdir)
97- fatal('cannot download the archive file')
97+ Install.fatal('cannot download the archive file')
9898 end
9999 else
100100 check_archive(filename)
@@ -119,7 +119,7 @@ module Install
119119 zf.close()
120120 rescue # except:
121121 FileUtils.remove_entry_secure(tmpdir)
122- fatal('cannot extract files from the archive')
122+ Install.fatal('cannot extract files from the archive')
123123 end
124124 Dir.glob(tmpdir) { |path|
125125 if File.directory?(path)
@@ -131,7 +131,6 @@ module Install
131131 File.chmod(st_mode | 128 | 256, path)
132132 end
133133 }
134-# print("EXTRACT: ", tmpdir, "\n")
135134 rename_files(tmpdir)
136135 return tmpdir
137136 end
@@ -146,7 +145,7 @@ module Install
146145 elsif File.exists?(File.join(tmpdir, 'plugin.txt'))
147146 filetype = 'plugin'
148147 else
149- fatal('cannot read install.txt from the archive')
148+ Install.fatal('cannot read install.txt from the archive')
150149 end
151150 else
152151 filetype = inst.get('type')
@@ -275,15 +274,13 @@ module Install
275274 end
276275
277276 def rename_files(basedir)
278-# print("RENAME: ", basedir, "\n")
279-# if os.name == 'nt' # XXX
280-# return
281-# end
277+ if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/ # XXX
278+ return
279+ end
282280 Dir.foreach(basedir) { |filename|
283281 next if /^\.+$/ =~ filename
284282 filename2 = filename.downcase
285283 path = File.join(basedir, filename2)
286-# print("PATH: ", path, "\n")
287284 if filename != filename2
288285 File.rename(File.join(basedir, filename), path)
289286 end
@@ -338,9 +335,9 @@ module Install
338335 end
339336
340337 def lower_files(top_dir)
341-# if os.name == 'nt' # XXX
342-# return
343-# end
338+ if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/ # XXX
339+ return
340+ end
344341 n = 0
345342 Dir.foreach(top_dir) { |filename|
346343 next if /^\.+$/ =~ filename
@@ -348,8 +345,8 @@ module Install
348345 path = File.join(top_dir, filename2)
349346 if filename != filename2
350347 File.rename(File.join(top_dir, filename), path)
351-# logging.info(
352-# 'renamed {0}'.format(File.join(top_dir, filename)))
348+ #logging.info(
349+ # 'renamed {0}'.format(File.join(top_dir, filename)))
353350 n += 1
354351 end
355352 if File.directory?(path)
@@ -380,13 +377,13 @@ module Install
380377
381378 def select(candidates)
382379 #assert len(candidates) >= 1
383- if len(candidates) == 1
380+ if candidates.length == 1
384381 return candidates[0]
385382 end
386383 ls = @treeview.get_model()
387384 ls.clear()
388385 for i, item in enumerate(candidates)
389- ls.append([i, item])
386+ ls << [i, item]
390387 end
391388 ts = @treeview.get_selection()
392389 ts.select_iter(ls.get_iter_first())
@@ -402,13 +399,12 @@ module Install
402399 def install_ghost(archive, tmpdir, homedir)
403400 # find install.txt
404401 inst = Home.read_install_txt(tmpdir)
405-# print("INST: ", inst, "\n")
406402 if inst == nil
407- fatal('install.txt not found')
403+ Install.fatal('install.txt not found')
408404 end
409405 target_dir = inst.get('directory')
410406 if target_dir == nil
411- fatal('"directory" not found in install.txt')
407+ Install.fatal('"directory" not found in install.txt')
412408 end
413409 prefix = File.join(homedir, 'ghost', target_dir)
414410 ghost_src = File.join(tmpdir, 'ghost', 'master')
@@ -448,7 +444,6 @@ module Install
448444 end
449445 balloon_name = nil
450446 if balloon_dir
451-# print("BALLOON DIR: ", balloon_dir, "\n")
452447 balloon_dir = Home.get_normalized_path(balloon_dir)
453448 balloon_dst = File.join(homedir, 'balloon', balloon_dir)
454449 if inst
@@ -459,7 +454,6 @@ module Install
459454 else
460455 balloon_src = balloon_dir
461456 end
462-# print("INSTALL.TXT(B): ", File.join(tmpdir, balloon_src), "\n")
463457 inst_balloon = Home.read_install_txt(
464458 File.join(tmpdir, balloon_src))
465459 if Dir.exists?(balloon_dst) and \
@@ -483,7 +477,7 @@ module Install
483477 end
484478 if Dir.exists?(prefix)
485479 inst_dst = Home.read_install_txt(prefix)
486- if inst.get('refresh', 0).to_i
480+ if inst.get('refresh', 0).to_i != 0
487481 # uninstall older versions of the ghost
488482 if confirm_refresh(prefix, 'ghost')
489483 mask = []
@@ -502,7 +496,7 @@ module Install
502496 end
503497 end
504498 # install files
505-# logging.info('installing {0} (ghost)'.format(archive))
499+ #logging.info('installing {0} (ghost)'.format(archive))
506500 install_files(filelist)
507501 # create SETTINGS
508502 path = File.join(prefix, 'SETTINGS')
@@ -514,7 +508,7 @@ module Install
514508 end
515509 rescue # except IOError as e:
516510 code, message = e.args
517-# logging.error('cannot write {0}'.format(path))
511+ #logging.error('cannot write {0}'.format(path))
518512 ensure
519513 f.close()
520514 end
@@ -528,7 +522,7 @@ module Install
528522 def install_supplement(archive, tmpdir, homedir)
529523 inst = Home.read_install_txt(tmpdir)
530524 if inst and inst.include?('accept')
531- logging.info('searching supplement target ...')
525+ #logging.info('searching supplement target ...')
532526 candidates = []
533527 begin
534528 dirlist = Dir.entries(File.join(homedir, 'ghost'))
@@ -538,7 +532,7 @@ module Install
538532 for dirname in dirlist
539533 path = File.join(homedir, 'ghost', dirname)
540534 if File.exists?(File.join(path, 'shell', 'surface.txt'))
541- continue # ghost.inverse(obsolete)
535+ next # ghost.inverse(obsolete)
542536 end
543537 desc = Home.read_descript_txt(
544538 File.join(path, 'ghost', 'master'))
@@ -546,8 +540,8 @@ module Install
546540 candidates << dirname
547541 end
548542 end
549- if not candidates
550- logging.info('not found')
543+ if candidates.empty?
544+ #logging.info('not found')
551545 return nil, nil, 4
552546 else
553547 target = self.select(candidates)
@@ -560,7 +554,7 @@ module Install
560554 path = File.join(path, 'shell', inst['directory'])
561555 else
562556 if not inst.include?('type')
563-# logging.error('supplement type not specified')
557+ #logging.error('supplement type not specified')
564558 else
565559 # logging.error('unsupported supplement type: {0}'.format(inst['type']))
566560 end
@@ -582,11 +576,11 @@ module Install
582576 # find install.txt
583577 inst = Home.read_install_txt(srcdir)
584578 if inst == nil
585- fatal('install.txt not found')
579+ Install.fatal('install.txt not found')
586580 end
587581 target_dir = inst.get('directory')
588582 if target_dir == nil
589- fatal('"directory" not found in install.txt')
583+ Install.fatal('"directory" not found in install.txt')
590584 end
591585 dstdir = File.join(homedir, 'balloon', target_dir)
592586 filelist = []
@@ -616,7 +610,7 @@ module Install
616610 end
617611 end
618612 # install files
619-# logging.info('installing {0} (balloon)'.format(archive))
613+ #logging.info('installing {0} (balloon)'.format(archive))
620614 install_files(filelist)
621615 return target_dir, inst.get('name'), 0
622616 end
@@ -631,7 +625,7 @@ module Install
631625 path = File.join(homedir, 'plugin', subdir)
632626 plugin = Home.read_plugin_txt(path)
633627 if plugin == nil
634- continue
628+ next
635629 end
636630 plugin_name, plugin_dir, startup, menu_items = plugin
637631 if plugin_name == name
@@ -648,7 +642,7 @@ module Install
648642 # find plugin.txt
649643 plugin = Home.read_plugin_txt(srcdir)
650644 if plugin == nil
651- fatal('failed to read plugin.txt')
645+ Install.fatal('failed to read plugin.txt')
652646 end
653647 plugin_name, plugin_dir, startup, menu_items = plugin
654648 # find files
@@ -662,7 +656,7 @@ module Install
662656 # uninstall older versions of the plugin
663657 uninstall_plugin(homedir, plugin_name)
664658 # install files
665-# print('installing {0} (plugin)'.format(archive))
659+ #logging.info('installing {0} (plugin)'.format(archive))
666660 install_files(filelist)
667661 return plugin_dir, plugin_name, 0
668662 end
@@ -677,7 +671,7 @@ module Install
677671 path = File.join(homedir, 'kinoko', subdir)
678672 kinoko = Home.read_kinoko_ini(path)
679673 if kinoko == nil
680- continue
674+ next
681675 end
682676 kinoko_name = kinoko['title']
683677 if kinoko_name == name
@@ -693,7 +687,7 @@ module Install
693687 # find kinoko.ini
694688 kinoko = Home.read_kinoko_ini(srcdir)
695689 if kinoko == nil
696- fatal('failed to read kinoko.ini')
690+ Install.fatal('failed to read kinoko.ini')
697691 end
698692 kinoko_name = kinoko['title']
699693 if kinoko['extractpath'] != nil
@@ -713,7 +707,7 @@ module Install
713707 # uninstall older versions of the kinoko
714708 uninstall_kinoko(homedir, kinoko_name)
715709 # install files
716-# logging.info('installing {0} (kinoko)'.format(archive))
710+ #logging.info('installing {0} (kinoko)'.format(archive))
717711 install_files(filelist)
718712 return dstdir, [kinoko_name, kinoko['ghost'], kinoko['category']], 0
719713 end
@@ -732,11 +726,11 @@ module Install
732726 # find install.txt
733727 inst = Home.read_install_txt(srcdir)
734728 if inst == nil
735- fatal('install.txt not found')
729+ Install.fatal('install.txt not found')
736730 end
737731 target_dir = inst.get('directory')
738732 if target_dir == nil
739- fatal('"directory" not found in install.txt')
733+ Install.fatal('"directory" not found in install.txt')
740734 end
741735 dstdir = File.join(homedir, 'nekodorif', 'skin', target_dir)
742736 # find files
@@ -751,7 +745,7 @@ module Install
751745 # uninstall older versions of the skin
752746 uninstall_nekoninni(homedir, target_dir)
753747 # install files
754-# logging.info('installing {0} (nekodorif skin)'.format(archive))
748+ #logging.info('installing {0} (nekodorif skin)'.format(archive))
755749 install_files(filelist)
756750 return target_dir, inst.get('name'), 0
757751 end
@@ -770,11 +764,11 @@ module Install
770764 # find install.txt
771765 inst = Home.read_install_txt(srcdir)
772766 if inst == nil
773- fatal('install.txt not found')
767+ Install.fatal('install.txt not found')
774768 end
775769 target_dir = inst.get('directory')
776770 if target_dir == nil
777- fatal('"directory" not found in install.txt')
771+ Install.fatal('"directory" not found in install.txt')
778772 end
779773 dstdir = File.join(homedir, 'nekodorif', 'katochan', target_dir)
780774 # find files
@@ -789,7 +783,7 @@ module Install
789783 # uninstall older versions of the skin
790784 uninstall_katochan(homedir, target_dir)
791785 # install files
792-# logging.info('installing {0} (nekodorif katochan)'.format(archive))
786+ #logging.info('installing {0} (nekodorif katochan)'.format(archive))
793787 install_files(filelist)
794788 return target_dir, inst.get('name'), 0
795789 end
@@ -814,7 +808,6 @@ module Install
814808 if not Dir.exists?(dirname)
815809 FileUtils.mkdir_p(dirname)
816810 end
817-# print("INSTALL FILES: ", from_path, " to ", to_path, "\n")
818811 FileUtils.copy(from_path, to_path)
819812 end
820813 end
--- a/lib/ninix/kinoko.rb
+++ b/lib/ninix/kinoko.rb
@@ -52,7 +52,6 @@ module Kinoko
5252 '', lambda {|a, b| return @parent.handle_request('NOTIFY', 'close')}],
5353 '/ui/popup/Exit'],
5454 }
55- @__skin_list = nil
5655 actions = Gtk::ActionGroup.new('Actions')
5756 entry = []
5857 for value in @__menu_list.values()
@@ -81,14 +80,13 @@ module Kinoko
8180
8281 def set_skin_menu(list) ## FIXME
8382 key = 'skin'
84- if list
85- menu = Gtk.Menu()
83+ if not list.empty?
84+ menu = Gtk::Menu.new
8685 for skin in list
87- item = Gtk.MenuItem(skin['title'])
88- item.signal_connect(
89- 'activate',
90- lambda {|a, k| return @parent.handle_request('NOTIFY', 'select_skin', k)},
91- [skin])
86+ item = Gtk::MenuItem.new(skin['title'])
87+ item.signal_connect('activate', skin) do |a, k|
88+ @parent.handle_request('NOTIFY', 'select_skin', k)
89+ end
9290 menu.add(item)
9391 item.show()
9492 end
@@ -119,42 +117,42 @@ module Kinoko
119117
120118 def finalize()
121119 @__running = false
122- self.target.detach_observer(self)
123- if self.skin != nil
124- self.skin.destroy()
120+ @target.detach_observer(self)
121+ if @skin != nil
122+ @skin.destroy()
125123 end
126124 end
127125
128126 def observer_update(event, args)
129- if self.skin == nil
127+ if @skin == nil
130128 return
131129 end
132130 if ['set position', 'set surface'].include?(event)
133- self.skin.set_position()
134- self.skin.show()
131+ @skin.set_position()
132+ @skin.show()
135133 elsif event == 'set scale'
136- scale = self.target.get_surface_scale()
137- self.skin.set_scale(scale)
134+ scale = @target.get_surface_scale()
135+ @skin.set_scale(scale)
138136 elsif event == 'hide'
139137 side = args
140138 if side == 0 # sakura side
141- self.skin.hide()
139+ @skin.hide()
142140 end
143141 elsif event == 'iconified'
144- self.skin.hide()
142+ @skin.hide()
145143 elsif event == 'deiconified'
146- self.skin.show()
144+ @skin.show()
147145 elsif event == 'finalize'
148- self.finalize()
146+ finalize()
149147 elsif event == 'move surface'
150148 side, xoffset, yoffset = args
151149 if side == 0 # sakura side
152- self.skin.set_position(xoffset, yoffset)
150+ @skin.set_position(xoffset, yoffset)
153151 end
154152 elsif event == 'raise'
155153 side = args
156154 if side == 0 # sakura side
157- self.skin.set_position() ## FIXME
155+ @skin.set_position() ## FIXME
158156 end
159157 else
160158 ##logging.debug('OBSERVER(kinoko): ignore - {0}'.format(event))
@@ -164,21 +162,25 @@ module Kinoko
164162 def load_skin()
165163 scale = @target.get_surface_scale()
166164 @skin = Skin.new(@accelgroup)
167- @skin.set_responsible(@target)
165+ @skin.set_responsible(self)
168166 @skin.load(@data, scale)
169- print("SKIN: ", @skin, "\n")
170167 end
171168
172169 def handle_request(event_type, event, *arglist, **argdict)
173170 #assert ['GET', 'NOTIFY'].include?(event_type)
174171 handlers = {
175- 'get_target_window' => lambda {|a| return self.target.surface.window[0].window}, # XXX
176- 'get_kinoko_position' => self.target.get_kinoko_position,
172+ 'get_target_window' => lambda { return @target.get_window }, # XXX
173+ 'get_kinoko_position' => lambda { return @target.get_kinoko_position }
177174 }
178- handler = handlers.get(event,
179- getattr(self, event,
180- lambda {|a| return nil})) ## FIXME
181- result = handler(*arglist, **argdict)
175+ if handlers.include?(event)
176+ result = handlers[event].call # no argument
177+ else
178+ if Kinoko.method_defined?(event)
179+ result = method(event).call(*arglist)
180+ else
181+ result = nil
182+ end
183+ end
182184 if event_type == 'GET'
183185 return result
184186 end
@@ -193,7 +195,7 @@ module Kinoko
193195 if @skin == nil
194196 return 0
195197 else
196- self.send_event('OnKinokoObjectCreate')
198+ send_event('OnKinokoObjectCreate')
197199 end
198200 @__running = true
199201 GLib::Timeout.add(10) { do_idle_tasks } # 10[ms]
@@ -209,8 +211,8 @@ module Kinoko
209211 end
210212
211213 def close()
212- self.finalize()
213- self.send_event('OnKinokoObjectDestroy')
214+ finalize()
215+ send_event('OnKinokoObjectDestroy')
214216 end
215217
216218 def send_event(event)
@@ -232,14 +234,14 @@ module Kinoko
232234 end
233235
234236 def select_skin(args)
235- self.send_event('OnKinokoObjectChanging')
236- self.skin.destroy()
237- self.data = args
238- self.load_skin()
239- if self.skin == nil
237+ send_event('OnKinokoObjectChanging')
238+ @skin.destroy()
239+ @data = args
240+ load_skin()
241+ if @skin == nil
240242 return 0
241243 else
242- self.send_event('OnKinokoObjectChanged')
244+ send_event('OnKinokoObjectChanged')
243245 end
244246 return 1
245247 end
@@ -263,18 +265,18 @@ module Kinoko
263265 @parent = parent
264266 end
265267
266- def handle_request(event_type, event, *arglist, **argdict)
268+ def handle_request(event_type, event, *arglist)
267269 #assert ['GET', 'NOTIFY'].include?(event_type)
268270 handlers = {
269271 }
270-# handler = handlers.get(event, getattr(self, event, nil))
271-# if handler == nil
272- if not handlers.include?(event)
273- result = @parent.handle_request(event_type, event, *arglist, **argdict)
272+ if handlers.include?(event)
273+ result = handlers[event].call # no argument
274274 else
275-# result = handler(*arglist, **argdict)
276- ## FIXME
277- result = class_eval(event) #( *arglist, **argdict)
275+ if Skin.method_defined?(event)
276+ result = method(event).call(*arglist)
277+ else
278+ result = @parent.handle_request(event_type, event, *arglist)
279+ end
278280 end
279281 if event_type == 'GET'
280282 return result
@@ -306,11 +308,9 @@ module Kinoko
306308 actors = {'' => []}
307309 end
308310 end
309- print("ACTORS: ", actors, "\n")
310311 @seriko = Seriko::Controller.new(actors)
311312 @seriko.set_responsible(self) ## FIXME
312313 path = File.join(@data['dir'], @data['base'])
313- print("PATH: ", path, "\n")
314314 begin
315315 @image_surface = Pix.create_surface_from_file(path)
316316 w = [8, (@image_surface.width * @__scale / 100).to_i].max
@@ -319,7 +319,6 @@ module Kinoko
319319 @parent.handle_request('NOTIFY', 'close')
320320 return
321321 end
322- print("SURFACE: ", w, " , ", h, "\n")
323322 @path = path
324323 @w, @h = w, h
325324 @darea = @window.darea # @window.get_child()
@@ -434,16 +433,14 @@ module Kinoko
434433 end
435434
436435 def update_frame_buffer()
437- print("UPDATE FRAME: ", @seriko.get_base_id, "\n")
438436 new_surface = create_image_surface(@seriko.get_base_id)
439437 #assert new_surface != nil
440438 # draw overlays
441439 for surface_id, x, y, method in @seriko.iter_overlays()
442- print("OVERLAY: ", surface_id, x, y, method, "\n")
443- if 1#begin
440+ begin
444441 overlay_surface = get_image_surface(surface_id)
445- else#rescue #except:
446- continue
442+ rescue #except:
443+ next
447444 end
448445 # overlay surface
449446 cr = Cairo::Context.new(new_surface)
@@ -451,7 +448,7 @@ module Kinoko
451448 cr.mask(overlay_surface, x, y)
452449 #del cr
453450 end
454- #self.darea.queue_draw_area(0, 0, w, h)
451+ #@darea.queue_draw_area(0, 0, w, h)
455452 @image_surface = new_surface
456453 @darea.queue_draw()
457454 end
@@ -499,7 +496,7 @@ module Kinoko
499496 @seriko.invoke(self, actor_id, update)
500497 end
501498
502- def delete() #widget, event)
499+ def delete()
503500 @parent.handle_request('NOTIFY', 'close')
504501 end
505502
--- a/lib/ninix/nekodorif.rb
+++ b/lib/ninix/nekodorif.rb
@@ -184,25 +184,20 @@ module Nekodorif
184184 return 1
185185 end
186186
187- def handle_request(event_type, event, *arglist, **argdict)
187+ def handle_request(event_type, event, *arglist)
188188 ##assert ['GET', 'NOTIFY'].include?(event_type)
189189 handlers = {
190190 'get_katochan_list' => lambda { return @katochan_list },
191191 'get_mode' => lambda { return @mode },
192192 }
193-# handler = handlers.get(event,
194-# getattr(self, event,
195-# lambda {|a| return nil})) ## FIXME
196-# result = handler(*arglist, **argdict)
197-# if not handlers.include?(event)
198-# result = @parent.handle_request(event_type, event, *arglist, **argdict)
199-# else
200193 if handlers.include?(event)
201- result = handlers[event].call #( *arglist, **argdict)
194+ result = handlers[event].call # no argument
202195 else
203- ## FIXME
204- print("REQ: ", Nekoninni.method_defined?(event), " , ", *arglist, "\n")
205- result = method(event).call(*arglist)#, **argdict)
196+ if Nekoninni.method_defined?(event)
197+ result = method(event).call(*arglist)
198+ else
199+ result = nil # XXX
200+ end
206201 end
207202 if event_type == 'GET'
208203 return result
@@ -217,7 +212,7 @@ module Nekodorif
217212 if @katochan != nil
218213 @katochan.update()
219214 end
220- #self.process_script()
215+ #process_script()
221216 return true
222217 end
223218
@@ -350,16 +345,18 @@ module Nekodorif
350345 @parent = parent
351346 end
352347
353- def handle_request(event_type, event, *arglist, **argdict)
348+ def handle_request(event_type, event, *arglist)
354349 ##assert ['GET', 'NOTIFY'].include?(event_type)
355350 handlers = {
356351 }
357-# handler = handlers.get(event, getattr(self, event, nil))
358-# if handler == nil
359352 if not handlers.include?(event)
360- result = @parent.handle_request(event_type, event, *arglist, **argdict)
353+ result = @parent.handle_request(event_type, event, *arglist)
361354 else
362- result = method(event).call(*arglist)#, **argdict)
355+ if Skin.method_defined?(event)
356+ result = method(event).call(*arglist)
357+ else
358+ result = nil
359+ end
363360 end
364361 if event_type == 'GET'
365362 return result
@@ -442,11 +439,11 @@ module Nekodorif
442439
443440 def set_position(reset=0)
444441 left, top, scrn_w, scrn_h = Pix.get_workarea()
445- if reset
442+ if reset != 0
446443 @x = left
447444 @y = top + scrn_h - @h
448445 else
449- if not @omni
446+ if @omni != 0
450447 @y = top + scrn_h - @h
451448 end
452449 end
@@ -455,7 +452,7 @@ module Nekodorif
455452
456453 def move(x_delta, y_delta)
457454 @x = @x + x_delta
458- if @omni
455+ if @omni != 0
459456 @y = @y + y_delta
460457 end
461458 set_position()
@@ -499,7 +496,6 @@ module Nekodorif
499496 else
500497 x, y, state = event.x, event.y, event.state
501498 end
502- #x, y = self.window.winpos_to_surfacepos(x, y, self.__scale)
503499 if state & Gdk::Window::ModifierType::BUTTON1_MASK
504500 if @x_root != nil and \
505501 @y_root != nil
@@ -601,11 +597,8 @@ module Nekodorif
601597 end
602598
603599 def redraw(widget, cr)
604- scale = @__scale
605- cr.scale(scale / 100.0, scale / 100.0)
606- cr.set_source(@image_surface, 0, 0)
607- cr.set_operator(Cairo::OPERATOR_SOURCE)
608- cr.paint()
600+ @window.set_surface(cr, @image_surface, @__scale)
601+ @window.set_shape(cr)
609602 end
610603
611604 def set_movement(timing)
@@ -690,7 +683,6 @@ module Nekodorif
690683 end
691684 @w, @h = w, h
692685 @window.update_size(@w, @h)
693- #self.darea.queue_draw_area(0, 0, self.w, self.h)
694686 @image_surface = new_surface
695687 @darea.queue_draw()
696688 end
@@ -701,9 +693,9 @@ module Nekodorif
701693 set_state('before')
702694 if @data.include?('category')
703695 category = @data['category'].split(',')
704- if category
696+ if not category.empty?
705697 if not CATEGORY_LIST.include?(category[0])
706- logging.warning('WARNING: unknown major category - {0}'.format(category[0]))
698+ #logging.warning('WARNING: unknown major category - {0}'.format(category[0]))
707699 ##self.data['category'] = self.CATEGORY_LIST[-1]
708700 end
709701 else
@@ -847,7 +839,7 @@ module Nekodorif
847839 if @settings['state'] == 'fall'
848840 update_surface()
849841 update_position()
850- if check_collision()
842+ if check_collision() != 0
851843 set_state('hit')
852844 @hit = 1
853845 if @parent.handle_request('GET', 'get_mode') == 1
@@ -858,11 +850,16 @@ module Nekodorif
858850 #pass ## FIXME
859851 end
860852 end
861- if check_mikire()
853+ if check_mikire() != 0
862854 set_state('dodge')
863855 end
864856 elsif @settings['state'] == 'hit'
865- if @hit_stop >= @data.get('hit.waittime', 0)
857+ if @data.include?('hit.waittime')
858+ wait_time = @data['hit.waittime']
859+ else
860+ wait_time = 0
861+ end
862+ if @hit_stop >= wait_time
866863 set_state('after')
867864 set_movement('after')
868865 if @parent.handle_request('GET', 'get_mode') == 1
@@ -879,7 +876,7 @@ module Nekodorif
879876 elsif @settings['state'] == 'after'
880877 update_surface()
881878 update_position()
882- if check_mikire()
879+ if check_mikire() != 0
883880 set_state('end')
884881 end
885882 elsif @settings['state'] == 'end'
--- a/lib/ninix/ngm.rb
+++ b/lib/ninix/ngm.rb
@@ -798,21 +798,20 @@ module NGM
798798 @parent = parent
799799 end
800800
801- def handle_request(event_type, event, *arglist, **argdict)
801+ def handle_request(event_type, event, *arglist)
802802 #assert event_type in ['GET', 'NOTIFY']
803803 handlers = {
804- 'get_home_dir' => lambda { return @home_dir },
805- 'network_update' => lambda { return network_update },
806- 'get' => lambda { return get(arglist[0]) }
804+ 'get_home_dir' => lambda {|*a| return @home_dir },
805+ 'network_update' => lambda {|*a| return network_update },
806+ 'get' => lambda {|*a| return get(a[0]) }
807807 }
808808 if handlers.include?(event)
809- result = handlers[event].call #( *arglist, **argdict)
809+ result = handlers[event].call(*arglist)
810810 else
811811 begin
812812 result = public_send(event, *arglist)
813813 rescue
814- result = @parent.handle_request(
815- event_type, event, *arglist, **argdict)
814+ result = @parent.handle_request(event_type, event, *arglist)
816815 end
817816 end
818817 if event_type == 'GET'
--- a/test/test-kinoko.rb
+++ b/test/test-kinoko.rb
@@ -17,8 +17,9 @@ module NinixTest
1717 @win.set_default_size(@surface.width, @surface.height)
1818 @win.show_all
1919 kinoko_list = Home.search_kinoko()
20+ print("K: ", kinoko_list, "\n")
2021 kinoko = Kinoko::Kinoko.new(kinoko_list)
21- print("K: ", kinoko, "\n")
22+ #print("K: ", kinoko, "\n")
2223 kinoko.load(kinoko_list.sample, self)
2324 Gtk.main
2425 end
@@ -26,10 +27,16 @@ module NinixTest
2627 def notify_event(event, *args) # dummy
2728 end
2829
30+ def get_window # dummy
31+ return @win
32+ end
33+
34+ def get_kinoko_position # dummy
35+ return 100, 200
36+ end
37+
2938 def handle_request(type, event, *a) # dummy
30- if event == 'get_kinoko_position'
31- return 0, 0
32- elsif event == 'get_preference' and a[0] == 'animation_quality'
39+ if event == 'get_preference' and a[0] == 'animation_quality'
3340 return 1
3441 end
3542 end