rm_window_creator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +1 -0
- data/lib/rm_window_creator.rb +6 -0
- data/lib/rm_window_creator/kernel/game.rb +67 -0
- data/lib/rm_window_creator/modules/creator.rb +38 -0
- data/lib/rm_window_creator/modules/draw.rb +77 -0
- data/lib/rm_window_creator/modules/packer.rb +78 -0
- data/lib/rm_window_creator/version.rb +3 -0
- data/rm_window_creator.gemspec +23 -0
- data/spec/spec_help.rb +0 -0
- data/spec/window_createor_spec.rb +0 -0
- metadata +94 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 yoshikizh
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# RmWindowCreator
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rm_window_creator'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rm_window_creator
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
RmWindowCreator::Window.selectable(x,y,w,h) do |config|
|
23
|
+
config.hack :default,:obj=>:actor, :max => 4, :col_max=> 1,
|
24
|
+
:fontsize=>14,:color=>Color.new(255,255,255,255),:start=>[0,0],:space=>[20,20],
|
25
|
+
:opacity => 255,:active=>true
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
actor 的配置:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
config.hack :face, :start => [0,0],:space=>[20,20],:size=>96
|
33
|
+
config.hack :character, :start => [0,0],:space=>[20,20]
|
34
|
+
config.hack :name, :start => [0,0],:space=>[20,20],:color=>Color.new(255,128,128,255),:fontsize=>18
|
35
|
+
config.hack :level, :start => [0,0],:space=>[20,20],:color=>Color.new(255,128,128,255),:fontsize=>16,:sub=>"等级"
|
36
|
+
config.hack :nickname, :start => [0,0],:space=>[20,20]
|
37
|
+
config.hack :hp, :start => [0,0],:space=>[20,20],:color=>Color.new(128,200,192,255)
|
38
|
+
config.hack :mp, :start => [0,0],:space=>[20,20],:color=>Color.new(0,255,0,255)
|
39
|
+
config.hack :tp, :start => [0,0],:space=>[20,20],:color=>Color.new(0,0,255,255)
|
40
|
+
config.hack :hp_gauge, :start => [0,0],:space=>[20,20]
|
41
|
+
config.hack :mp_gauge, :start => [0,0],:space=>[20,20]
|
42
|
+
config.hack :tp_gauge, :start => [0,0],:space=>[20,20]
|
43
|
+
```
|
44
|
+
|
45
|
+
item , equipment , armor 等的配置:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
config.hack :icon, :start => [0,0],:space=>[20,20]
|
49
|
+
config.hack :desc, :start => [0,0],:space=>[20,20]
|
50
|
+
config.hack :price, :start => [0,0],:space=>[20,20]
|
51
|
+
config.hack :gold, :pos=>[300,300]
|
52
|
+
config.hack :item_rect, :col_max => 1,:spacing=>32,:item_max=>4,:item_height=>32,:item_width=>32
|
53
|
+
config.hack :background,:btm=>"system/xxx.jpg",:x=>0,:y=>0
|
54
|
+
config.hack :handler, :ok => method(:command_ok),:cancel=> method(:command_cancel)
|
55
|
+
```
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Game_Actor < Game_Battler
|
2
|
+
include Creator::Draw::GameActor
|
3
|
+
end
|
4
|
+
class RPG::BaseItem
|
5
|
+
include Creator::Draw::BaseItem
|
6
|
+
end
|
7
|
+
|
8
|
+
class RPG::Item < RPG::UsableItem
|
9
|
+
include Creator::Draw::Item
|
10
|
+
end
|
11
|
+
|
12
|
+
class Window_Custom_Selectable < Window_Selectable
|
13
|
+
include RmWindowCreator
|
14
|
+
#--------------------------------------------------------------------------
|
15
|
+
# ● 定义实例变量
|
16
|
+
#--------------------------------------------------------------------------
|
17
|
+
class << self
|
18
|
+
attr_reader :config
|
19
|
+
def create(*args,&blk)
|
20
|
+
obj = born(self,*args)
|
21
|
+
blk.call obj.config if blk
|
22
|
+
check_default obj
|
23
|
+
check_background obj
|
24
|
+
check_item_rect obj
|
25
|
+
check_handler obj
|
26
|
+
obj.set_background if obj.respond_to? :set_background
|
27
|
+
obj.refresh if obj.respond_to? :refresh
|
28
|
+
obj.update if obj.respond_to? :update
|
29
|
+
obj.activate if obj.config.default[:active]
|
30
|
+
obj
|
31
|
+
end
|
32
|
+
end
|
33
|
+
#--------------------------------------------------------------------------
|
34
|
+
# ● 初始化对象
|
35
|
+
#-------------------------------------------------------------------------
|
36
|
+
def initialize(x, y, width , height)
|
37
|
+
super(x, y, width, height)
|
38
|
+
self.index = 0
|
39
|
+
end
|
40
|
+
#--------------------------------------------------------------------------
|
41
|
+
# ● 刷新
|
42
|
+
#--------------------------------------------------------------------------
|
43
|
+
def refresh
|
44
|
+
contents.clear
|
45
|
+
default = config.default
|
46
|
+
gold = config.gold if config.respond_to? :gold
|
47
|
+
obj = default[:obj]
|
48
|
+
%w{face character name lv nickname hp mp tp hp_gauge mp_gauge tp_gauge}.each do |m|
|
49
|
+
self.send("_draw_#{m}",self)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def dispose
|
54
|
+
super
|
55
|
+
instance_variables.each do |varname|
|
56
|
+
ivar = instance_variable_get(varname)
|
57
|
+
if ivar.is_a?(Sprite)
|
58
|
+
ivar.dispose
|
59
|
+
ivar.bitmap.dispose unless ivar.bitmap.nil?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def update
|
65
|
+
super
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
module RmWindowCreator
|
3
|
+
def self.included(base)
|
4
|
+
base.extend Packer
|
5
|
+
end
|
6
|
+
def method_missing(method_name,*args)
|
7
|
+
# face character name level nickname hp mp tp hp_gauge mp_gauge tp_gauge
|
8
|
+
if method_name =~ /^_draw_(.*)$/
|
9
|
+
m = $1
|
10
|
+
window = args.first ; btm = window.contents
|
11
|
+
cfg = window.config
|
12
|
+
hash = cfg.send(m) if cfg.respond_to? m
|
13
|
+
body = cfg.default[:obj]
|
14
|
+
if $1 == "face"
|
15
|
+
puts "face"
|
16
|
+
puts hash
|
17
|
+
end
|
18
|
+
window.items.each_with_index do |item,index|
|
19
|
+
if item
|
20
|
+
pos = window.items.first.send :get_pos_and_margin,index,default,hash
|
21
|
+
window.items.first.send("#{m}!",window,cfg.default,hash,item,index,pos)
|
22
|
+
end
|
23
|
+
end if window.items.first.respond_to? "#{m}!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Window
|
28
|
+
module_function
|
29
|
+
def base(*args,&blk)
|
30
|
+
Window_Custom_Base.create(*args,&blk)
|
31
|
+
end
|
32
|
+
def selectable(*args,&blk)
|
33
|
+
Window_Custom_Selectable.create(*args,&blk)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Scene ; end # scene hack 还未写
|
38
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
module RmWindowCreator
|
3
|
+
module Draw
|
4
|
+
module GameActor
|
5
|
+
def face! w,default,hash,item,index,pos
|
6
|
+
w.draw_actor_face(item, pos.first, pos.last,hash[:size] ? hash[:size] : nil) if pos
|
7
|
+
end
|
8
|
+
def character! w,default,hash,item,index,pos
|
9
|
+
w.draw_actor_graphic(item, pos.first, pos.last+32) if pos
|
10
|
+
end
|
11
|
+
|
12
|
+
# draw_actor_name(actor, x, y)
|
13
|
+
# draw_actor_level(actor, x, y + line_height * 1)
|
14
|
+
# draw_actor_icons(actor, x, y + line_height * 2)
|
15
|
+
# draw_actor_class(actor, x + 120, y)
|
16
|
+
# draw_actor_hp(actor, x + 120, y + line_height * 1)
|
17
|
+
# draw_actor_mp(actor, x + 120, y + line_height * 2)
|
18
|
+
# draw_actor_hp_gauge(actor, x, y, width = 114)
|
19
|
+
|
20
|
+
def name! w,default,hash,item,index,pos
|
21
|
+
w.draw_actor_name(item, pos.first, pos.last) if pos
|
22
|
+
end
|
23
|
+
|
24
|
+
def level! w,default,hash,item,index,pos
|
25
|
+
w.draw_actor_leve(item, pos.first, pos.last) if pos
|
26
|
+
end
|
27
|
+
|
28
|
+
def nickname! w,default,hash,item,index,pos
|
29
|
+
w.draw_actor_class(item, pos.first, pos.last) if pos
|
30
|
+
end
|
31
|
+
|
32
|
+
def hp! w,default,hash,item,index,pos ;
|
33
|
+
#w.draw_actor_hp(item, pos.first, pos.last) if pos
|
34
|
+
w.contents.draw_text(pos.first, pos.last, 30, w.line_height, Vocab::hp_a)
|
35
|
+
w.draw_current_and_max_values(pos.first, pos.last, 124, item.hp, item.mhp,
|
36
|
+
w.hp_color(item), w.normal_color)
|
37
|
+
end
|
38
|
+
|
39
|
+
def mp! w,default,hash,item,index,pos ;
|
40
|
+
#w.draw_actor_mp(item, pos.first, pos.last) if pos
|
41
|
+
end
|
42
|
+
|
43
|
+
def hp_gauge! w,default,hash,item,index,pos ;
|
44
|
+
w.draw_gauge(pos.first, pos.last, 124, item.hp_rate, w.hp_gauge_color1, w.hp_gauge_color2)
|
45
|
+
w.change_color(w.system_color)
|
46
|
+
#w.draw_actor_hp_gauge(item, pos.first, pos.last) if pos
|
47
|
+
end
|
48
|
+
|
49
|
+
def mp_gauge! w,default,hash,item,index,pos ; end
|
50
|
+
def tp_gauge! w,default,hash,item,index,pos ; end
|
51
|
+
private
|
52
|
+
def get_pos_and_margin(index,default,hash)
|
53
|
+
if start = hash[:start] ? hash[:start] : default[:start]
|
54
|
+
x,y = start.first,start.last
|
55
|
+
end
|
56
|
+
if space = hash[:space] ? hash[:space] : default[:space]
|
57
|
+
margin_x,margin_y = space.first,space.last
|
58
|
+
end
|
59
|
+
if start && space
|
60
|
+
return x + margin_x * index , y + margin_y * index
|
61
|
+
else
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
module BaseItem
|
68
|
+
def icon! ; end
|
69
|
+
def name! ; end
|
70
|
+
def desc! ; end
|
71
|
+
end
|
72
|
+
|
73
|
+
module Item
|
74
|
+
def price! ; end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#encoding:utf-8
|
2
|
+
module RmWindowCreator
|
3
|
+
module Packer
|
4
|
+
class CleanRoom ; end
|
5
|
+
def born(kls,*args,&blk)
|
6
|
+
obj = kls.new(*args)
|
7
|
+
obj.instance_eval do
|
8
|
+
@config = CleanRoom.new
|
9
|
+
class << @config
|
10
|
+
def hack(method_name,args)
|
11
|
+
self.class.class_eval do
|
12
|
+
define_method method_name do
|
13
|
+
return args
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
eval "def config ; @config ; end"
|
19
|
+
end
|
20
|
+
obj
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_default obj
|
24
|
+
if d = obj.config.default
|
25
|
+
if d[:obj]
|
26
|
+
obj.class.class_eval do
|
27
|
+
define_method :items do
|
28
|
+
@items ||= case d[:obj]
|
29
|
+
when :actor ; $game_party.members
|
30
|
+
when :item ; $game_party.items
|
31
|
+
when :weapon ; $game_party.weapons
|
32
|
+
when :armor ; $game_party.armors
|
33
|
+
when :equip_items ; $game_party.equip_items
|
34
|
+
when :all_items ; $game_party.all_items
|
35
|
+
end
|
36
|
+
@items.take(d[:max]) if d[:max]
|
37
|
+
end
|
38
|
+
define_method :item do
|
39
|
+
@items[self.index]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
obj.opacity = d[:opacity] || 255
|
44
|
+
end
|
45
|
+
end
|
46
|
+
def check_background obj
|
47
|
+
if obj.config.respond_to? :background
|
48
|
+
b = obj.config.background
|
49
|
+
obj.class.class_eval do
|
50
|
+
define_method :set_background do
|
51
|
+
@background = Sprite.create do |sp|
|
52
|
+
b[:btm] =~ /^(.*)\/(.*)$/
|
53
|
+
sp.attrset :x=> b[:x] , :y=> b[:y] , :bitmap=>Cache.send($1,$2)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
def check_item_rect obj
|
60
|
+
if r = obj.config.item_rect
|
61
|
+
obj.class.class_eval do
|
62
|
+
define_method :item_max do r[:item_max] || super ; end
|
63
|
+
define_method :col_max do r[:col_max] || super ; end
|
64
|
+
define_method :spacing do r[:spacing] || super ; end
|
65
|
+
define_method :item_height do r[:item_height] || super ; end
|
66
|
+
define_method :item_width do r[:item_width] || super ; end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
def check_handler obj
|
71
|
+
if obj.config.respond_to? :handler
|
72
|
+
hander = obj.config.handler
|
73
|
+
obj.set_handler(:ok, handler[:ok]) if handler[:ok]
|
74
|
+
obj.set_handler(:cancel, handler[:cancel]) if handler[:cancel]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rm_window_creator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "rm_window_creator"
|
8
|
+
gem.version = RmWindowCreator::VERSION
|
9
|
+
gem.authors = ["yoshikizh"]
|
10
|
+
gem.email = ["177365340@qq.com"]
|
11
|
+
gem.description = "window creator for rm"
|
12
|
+
gem.summary = "window creator for rm"
|
13
|
+
gem.homepage = "https://github.com/yoshikizh/rm_window_creator"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_development_dependency "bundler", ">= 1.0.0"
|
22
|
+
|
23
|
+
end
|
data/spec/spec_help.rb
ADDED
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rm_window_creator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- yoshikizh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.0
|
46
|
+
description: window creator for rm
|
47
|
+
email:
|
48
|
+
- 177365340@qq.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/rm_window_creator.rb
|
59
|
+
- lib/rm_window_creator/kernel/game.rb
|
60
|
+
- lib/rm_window_creator/modules/creator.rb
|
61
|
+
- lib/rm_window_creator/modules/draw.rb
|
62
|
+
- lib/rm_window_creator/modules/packer.rb
|
63
|
+
- lib/rm_window_creator/version.rb
|
64
|
+
- rm_window_creator.gemspec
|
65
|
+
- spec/spec_help.rb
|
66
|
+
- spec/window_createor_spec.rb
|
67
|
+
homepage: https://github.com/yoshikizh/rm_window_creator
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.24
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: window creator for rm
|
91
|
+
test_files:
|
92
|
+
- spec/spec_help.rb
|
93
|
+
- spec/window_createor_spec.rb
|
94
|
+
has_rdoc:
|