-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRS_PictureVariables.rb
75 lines (73 loc) · 2.08 KB
/
RS_PictureVariables.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
#================================================================
# The MIT License
# Copyright (c) 2020 biud436
# ---------------------------------------------------------------
# Free for commercial and non commercial use.
#================================================================
#==============================================================================
# Author : biud436
# Date : 2018.05.28
# Description : 그림의 크기를 특정 변수에 대입합니다.
#==============================================================================
$imported = {} if $imported.nil?
$imported["RS_PictureVariables"] = true
module RS
SCAN_IMAGE_WIDTH = /(?:이미지 가로 크기)/i
SCAN_IMAGE_HEIGHT = /(?:이미지 세로 크기)/i
end
class Sprite_Picture < Sprite
alias get_size_update update
def update
get_size_update
get_size
end
def get_size
return false if @picture.name.empty? or self.bitmap == nil
return false if not @picture.valid_variable_size?
w = self.bitmap.width
h = self.bitmap.height
@picture.get_size(w, h)
end
end
class Game_Picture
attr_reader :width, :height
alias variable_ids_initialize initialize
def initialize(number)
variable_ids_initialize(number)
init_variables
end
def init_variables
@variable_ids = [0, 0]
@width = 0
@height = 0
end
def set_ids(*arg)
return if arg == nil
@variable_ids[0] = arg[0]
@variable_ids[1] = arg[1]
end
def ids
@variable_ids
end
def get_size(w, h)
@width = w
@height = h
if valid_variable_size?
$game_variables[ids[0]] = @width
$game_variables[ids[1]] = @height
end
end
def valid_variable_size?
return !@variable_ids.include?(0)
end
end
class Game_Interpreter
alias xxxx_command_231 command_231
def command_231
xxxx_command_231
valid = @params[3] != 0
valid = $data_system.variables[@params[4]].slice(RS::SCAN_IMAGE_WIDTH) if valid
valid = $data_system.variables[@params[5]].slice(RS::SCAN_IMAGE_HEIGHT) if valid
screen.pictures[@params[0]].set_ids(@params[4], @params[5]) if valid
end
end